美文网首页
内存的消耗最少渲染快速切圆角

内存的消耗最少渲染快速切圆角

作者: 忧郁男生 | 来源:发表于2017-03-08 10:21 被阅读0次

UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 100, 30)];

//    image.image = [UIImage imageNamed:@"newfeatures0"];

image.backgroundColor = [UIColor redColor];

[self.view addSubview:image];

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:image.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(8, 8)];

CAShapeLayer *layer = [[CAShapeLayer alloc] init];

layer.path = maskPath.CGPath;

image.layer.mask = layer;

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRect:image.bounds];

[maskPath appendPath:[UIBezierPath bezierPathWithRoundedRect:image.bounds cornerRadius:10]];

CAShapeLayer *shapeLayer = [[CAShapeLayer alloc] init];

shapeLayer.path = maskPath.CGPath;

//    shapeLayer.frame = image.bounds;

shapeLayer.fillColor = [UIColor whiteColor].CGColor;

shapeLayer.fillRule = kCAFillRuleEvenOdd;

[image.layer addSublayer:shapeLayer];

相关文章

网友评论

      本文标题:内存的消耗最少渲染快速切圆角

      本文链接:https://www.haomeiwen.com/subject/smqbgttx.html