我正在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