美文网首页
如何根据自己的需要裁剪控件的边角

如何根据自己的需要裁剪控件的边角

作者: 飞雨2013 | 来源:发表于2016-01-06 17:53 被阅读25次

UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 300, 100, 100)];

imageView.image = [UIImage imageNamed:@"屏幕快照 2016-01-06 17.44.20"];

[self.view addSubview:imageView];

UIBezierPath * maskPath = [UIBezierPath bezierPathWithRoundedRect:imageView.bounds byRoundingCorners:UIRectCornerBottomLeft|UIRectCornerTopLeft cornerRadii:CGSizeMake(20, 20)];

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

maskLayer.frame = imageView.bounds;

maskLayer.path = maskPath.CGPath;

imageView.layer.mask = maskLayer;

相关文章

网友评论

      本文标题:如何根据自己的需要裁剪控件的边角

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