如果是在VC中操作,需要在viewDidLayoutSubviews方法里
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
CGFloat radius = 36; // 圆角大小
UIRectCorner corner = UIRectCornerBottomLeft | UIRectCornerBottomRight;
UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:self.backImageV.bounds byRoundingCorners:corner cornerRadii:CGSizeMake(radius, radius)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.backImageV.bounds;
maskLayer.path = path.CGPath;
self.backImageV.layer.mask = maskLayer;
}
或者在其他地方,给一个延时:
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//
// CGFloat radius = 36; // 圆角大小
// UIRectCorner corner = UIRectCornerBottomLeft | UIRectCornerBottomRight;
// UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:self.backImageV.bounds byRoundingCorners:corner cornerRadii:CGSizeMake(radius, radius)];
// CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
// maskLayer.frame = self.backImageV.bounds;
// maskLayer.path = path.CGPath;
// self.backImageV.layer.mask = maskLayer;
//
//
// });
相关文章
暂无评论...