它会把我为什么这个代码,里面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