您的位置:首页 > 产品设计 > UI/UE

【iOS学习】三、利用UIBezierPath绘图

2015-07-22 17:01 567 查看
// 绘制一个屏幕能容下最大的园,找到最长半径

- (void) drawRect:(CGRect)rect
{
CGRect bounds = self.bounds;
CGPoint center;
center.x = bounds.origin.x + bounds.size.width / 2.0;
center.y = bounds.origin.y + bounds.size.height / 2.0;
// 选择较小的数值作为半径
float radius = (MIN(bounds.size.width , bounds.size.height) / 2.0);
// 开始绘制
UIBezierPath *path = [[UIBezierPath alloc] init];
[path addArcWithCenter:center // 圆心所在位置
radius:radius // 半径长度
startAngle:0.0 // 开始角度 (3点钟方向为起始角度)
endAngle:M_PI *2.0 //结束角度 (0~2π为一个整圆)
clockwise:YES]; // YES为顺时针,NO为逆时针

[path stroke]; //绘制路径
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios BezierPath