我正在Xcode版本6.1.1和iOS 8.1中开发我的应用程序,其中我需要根据设计在图像视图中围绕左上角和右上角。图像视图中的选择性圆角 - iOS
我以前用下面的代码,它正常工作在Xcode以前的版本:
UIImageView *locationImage = (UIImageView *)[cell viewWithTag:101];
UIBezierPath *maskPath1;
maskPath1 = [UIBezierPath bezierPathWithRoundedRect:locationImage.bounds
byRoundingCorners:(UIRectCornerTopRight | UIRectCornerTopLeft)
cornerRadii:CGSizeMake(5.0, 5.0)];
CAShapeLayer *maskLayer1 = [[CAShapeLayer alloc] init];
maskLayer1.frame = locationImage.bounds;
maskLayer1.path = maskPath1.CGPath;
locationImage.layer.mask = maskLayer1;
现在我得到的左上角圆,但没有合适的一个。我知道代码是正确的,因为如果我将它应用于不受约束的图像视图,它运作良好,但我需要将项目约束到视图。我使用自动布局。
链接到图片:https://www.dropbox.com/s/orisd8gzbdhsr4z/round-corners.tiff?dl=0
有件事我做错了吗?我怎样才能正确地调整两个角落?
在此先感谢
*对不起,我的英语
可能重复(http://stackoverflow.com/questions/14866450/round-some -corners-of-uiview-and-round-the-view-s-layer-s-border) – 2015-02-24 10:33:44
感谢您的建议,但是相关帖子使用相同的代码来四舍五入,只需添加一个笔划(其中I不需要),并以相同的方式工作:绕左上角。 – cmacera 2015-02-24 11:00:43