2013-07-31 62 views
5

有沒有辦法讓我的圖像看起來像這樣(圓角和輕邊框)。 enter image description hereiOS圓角有邊界的UIImage

我正在考慮創建一箇中間透明的白色面具放置在上面,這樣會起作用嗎?

+0

檢查此鏈接了 - 它引用UIWebViews中,但它是UIImageViews的一樣 - http://iosdevelopertips.com/cocoa/add-rounded-corners-and-border-to-uiwebview.html – wakachamo

+0

檢查此http ://stackoverflow.com/a/1651383/1615838 –

+1

有沒有解決方案爲你工作?請給出一些反饋,upvote並接受一個答案,以便將其從未答覆部分中刪除。 –

回答

0

您將要查看QuartzCore docs,特別是CALayer中的cornerRadius,borderColor和borderWidth屬性。

17

你可以做到這一點,但不是編輯你的UIImage,只需在你的UIImageView中做到這一點。

首先,添加QuartzCore頭

#import <QuartzCore/QuartzCore.h> 

然後,編輯下面的屬性,如你所願。

imageView.layer.cornerRadius = 5.0; 
imageView.layer.borderColor = [[UIColor grayColor] CGColor]; 
imageView.layer.borderWidth = 2.0; 
imageView.layer.masksToBounds = YES;