码迷,mamicode.com
首页 > 其他好文 > 详细

作图flowerView

时间:2014-11-06 10:55:44      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:ios

作图flowerView

by 伍雪颖

bubuko.com,布布扣
- (void)drawRect:(CGRect)rect{
    CGSize size = self.bounds.size;
    CGFloat margin = 10;
    CGFloat radius = rintf(MIN(size.height - margin,size.width - margin)/4);
    CGFloat xOffset,yOffset;
    CGFloat offset = rintf((size.height - size.width)/2);
    if (offset > 0) {
        xOffset = rint(margin/2);
        yOffset = offset;
    }else {
        xOffset = -offset;
        yOffset = rint(margin/2);
    }
    [[UIColor redColor] setFill];
    UIBezierPath *path = [UIBezierPath bezierPath];
    [path addArcWithCenter:CGPointMake(radius*2+xOffset, radius+yOffset) radius:radius startAngle:-M_PI endAngle:0 clockwise:YES];
    [path addArcWithCenter:CGPointMake(radius*3+xOffset, radius*2+yOffset) radius:radius startAngle:-M_PI_2 endAngle:M_PI_2 clockwise:YES];
    [path addArcWithCenter:CGPointMake(radius*2+xOffset, radius*3+yOffset) radius:radius startAngle:0 endAngle:M_PI clockwise:YES];
    [path addArcWithCenter:CGPointMake(radius+xOffset, radius*2+yOffset) radius:radius startAngle:M_PI_2 endAngle:-M_PI_2 clockwise:YES];
    [path closePath];
    [path fill];
}


作图flowerView

标签:ios

原文地址:http://blog.csdn.net/rainlesvio/article/details/40857281

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!