访次: AmazingCounters.com 次

使用CAShapeLayer画视图尖角

x y z 分别是尖角的三个顶点的x坐标,从左到右排列      后面的[UIScreen mainScreen].bounds.size.height -65 是y坐标  与x坐标一一对应

- (void)shapeChange:(int)x Pointy:(int)y Pointz:(int)z{

    /*形状*/

    self.shapeLayer = [CAShapeLayer layer];

    //self.shapeLayer.strokeColor = [UIColor greenColor].CGColor;

    self.shapeLayer.fillColor = [UIColor whiteColor].CGColor;

    self.shapeLayer.lineWidth = 1;

    /*路径*/

    CGMutablePathRef path = CGPathCreateMutable();

    CGPathMoveToPoint(path, NULL,x ,[UIScreen mainScreen].bounds.size.height -65);

    CGPathAddLineToPoint(path, NULL, y, [UIScreen mainScreen].bounds.size.height -53);

    CGPathAddLineToPoint(path, NULL, z, [UIScreen mainScreen].bounds.size.height -65);

    self.shapeLayer.path = path;

    self.shapeLayer.frame = self.heatab

    .view.bounds;

        [self.bgview.layer addSublayer:self.shapeLayer]; 

}

posted @ 2016-08-23 17:48  JusDoit  阅读(295)  评论(0编辑  收藏  举报