它會把我爲什麼這個代碼,裏面drawRect:
,工作原理:爲什麼 - [UIColor setFill]在不參考繪圖上下文的情況下工作?
UIBezierPath *buildingFloor = [[UIBezierPath alloc] init];
// draw the shape with addLineToPoint
[[UIColor colorWithRed:1 green:0 blue:0 alpha:1.0] setFill]; // I'm sending setFill to UIColor object?
[buildingFloor fill]; // Fills it with the current fill color
我的觀點是,在UIColor
對象獲得的消息setFill
然後以某種方式堆棧理解這UIColor
現在將填充顏色,ISN」這只是奇怪和錯誤?至少我希望通過調用一些CGContext
方法來設置填充...但現在,不是代表顏色,而是繼續並且做一些事情來改變我的繪圖的上下文。
有人可以解釋幕後發生了什麼,因爲我完全迷失在這裏嗎?
我沒有在發佈前檢查這些引用:
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIColor_Class/Reference/Reference.html http://developer.apple.com/library/ios/#documentation/uikit/reference/UIBezierPath_class/Reference/Reference.html
多謝@馬特,特別是對鏈接,這將是非常有用的我:) – 2013-05-09 16:41:15
你的書是真的很有幫助。最後,有人以一種合理的方式分解了圖形上下文和UIKit與CoreGraphics的概念!謝謝。 – d512 2013-12-12 22:34:06
很高興能幫到你!最初我也發現了同樣的事情,所以我花了很多精力來解釋清楚。 – matt 2013-12-13 00:56:53