我不明白为什么这段代码能在drawRect:
方法中正常工作:
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
会成为填充颜色,这是不是很奇怪和错误的?至少我希望通过调用某些CGContext
方法来设置填充。但是现在,UIColor
不再仅代表一种颜色,它还做了一些改变我的绘图上下文的事情。有人能解释一下背后发生了什么吗?因为我完全迷失了。
在发布之前,我查看了以下文献参考资料: 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