【发布时间】:2018-03-01 08:18:17
【问题描述】:
我需要围绕我的图像视图和 uiview 的特定角落 Imgview 左上和右上 查看左下角和右下角。
我探索并找到了这个方法
[self setMaskTo:_viewBookNow byRoundingCorners:UIRectCornerBottomLeft];
[self setMaskTo:_viewBookNow byRoundingCorners:UIRectCornerBottomRight|UIRectCornerBottomRight];
[self setMaskTo:_imgVAnimal byRoundingCorners:UIRectCornerTopRight];
[self setMaskTo:_imgVAnimal byRoundingCorners:UIRectCornerTopLeft];
方法定义是这样的
- (void)setMaskTo:(UIView*)view byRoundingCorners:(UIRectCorner)corners
{
UIBezierPath *rounded = [UIBezierPath bezierPathWithRoundedRect:view.bounds
byRoundingCorners:corners
cornerRadii:CGSizeMake(8.0, 8.0)];
CAShapeLayer *shape = [[CAShapeLayer alloc] init];
[shape setPath:rounded.CGPath];
view.layer.mask = shape;
}
但它仅适用于视图的左角,而图像不适用于右角。
请推荐
谢谢
【问题讨论】:
-
使用
clipsToBounds = true&maskstobounds = true试试 -
属性掩码边界不是为了查看。显示此错误。
-
不工作.....
-
使用
view.layer.masktobounds = true它是一个图层属性。
标签: ios objective-c iphone uiview