Ben*_*n H 0 drawing core-graphics objective-c ios
我在图层委托中有以下代码.它只是绘制一个蓝色圆圈.它在32位iOS设备上运行完美,但在64位iOS设备上没有任何效果.为什么?
-(void) drawLayer:(CALayer *)layer inContext:(CGContextRef)context
{
CGContextAddArc(context, 100., 100., 10., -M_PI, M_PI, YES);
CGContextSetFillColorWithColor(context, [UIColor blueColor].CGColor);
CGContextFillPath(context);
}
Run Code Online (Sandbox Code Playgroud)
弄清楚了.将M_PI转换为浮点解决了问题.这必须与CGContextAddArc采用CGFloat参数这一事实有关,而CGFloat在32位与64位平台上的定义不同.在32位上,它是一个浮点数,在64位上它是一个双倍.
CGContextAddArc(context, 100., 100., 10., -(float)M_PI, (float)M_PI, YES);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
493 次 |
最近记录: |