五角大楼画一个小圆圈戴:

- (void)drawPentagon{

    //(1)UIBezierPath对象

    UIBezierPath *aPath = [UIBezierPathbezierPath];

    //開始点

    [aPath moveToPoint:CGPointMake(100.0,1.0)];

    //划线点

    [aPath addLineToPoint:CGPointMake(200.0,40.0)];

    [aPath addLineToPoint:CGPointMake(160,140)];

    [aPath addLineToPoint:CGPointMake(40.0,140)];

    [aPath addLineToPoint:CGPointMake(0.0,40.0)];

    [aPath closePath];

    

    //设置定点是个5*5的小圆形(自己加的)

    UIBezierPath *path = [UIBezierPathbezierPathWithOvalInRect:CGRectMake(100-5/2.0, 0, 5, 5)];

    [aPath appendPath:path];

    

    //(2)加到CAShapeLayer,效果出来了

    CAShapeLayer *shapelayer = [CAShapeLayerlayer];

    //设置边框颜色

    shapelayer.strokeColor = [[UIColorredColor]CGColor];

    //设置填充颜色

    shapelayer.fillColor = [[UIColorwhiteColor]CGColor];

    //就是这句话在关联彼此(UIBezierPath和CAShapeLayer):

    shapelayer.path = aPath.CGPath;

    [self.view.layeraddSublayer:shapelayer];

}

版权声明:本文博客原创文章。博客,未经同意,不得转载。