我試圖找到實現圓角矩形的最佳方式(例如像iphone圖標一樣的looling)。我的搜索建議使用UIBezierPath。如何使用UIBezierPath修復無效的上下文0x0?
爲了測試類我做了一個新的Xcode模板(單一視圖應用),基本上只是加入的ViewController的viewDidLoad以下行:
UIBezierPath* path = [UIBezierPath
bezierPathWithRoundedRect: CGRectMake(10, 10, 120, 120)
cornerRadius: 5];
[[UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:1.0] setFill];
[path stroke];
[path fill];
現在,我得到幾個」 ......無效的上下文爲0x0錯誤...」。我認爲我必須先設置一個上下文?!但是,我該如何做,或者如果不能解決這些錯誤呢?
我對這個錯誤的搜索有幾個帖子。不幸的是,他們所有人似乎都有相當複雜的編碼。但我很確定,我在這裏只是有一個非常基本的誤解。
謝謝!
我建議閱讀[石英2D編程指南(https://developer.apple.com/library/ios/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction/Introduction.html#//apple_ref/doc/uid/ TP30001066)。 – Desdenova 2014-10-07 12:09:14
@Desdenova謝謝!這看起來不錯 - 我會檢查它。 – McMini 2014-10-07 12:15:29