先前一直做UI用的是storyboard,想給一個label加邊框。
而已知的加邊框什么的都是用代碼。
然后就在viewDidLoad里加了進去下面幾行
label.layer.borderWidth=1;
label.layer.borderColor=[UIColor redColor].CGColor;
那么,該如何在storyboard里設(shè)置layer呢?
去Google嘍。
以下是我找的

在紅圈圈出的地方,我們可以在其中寫上layer的屬性,
當(dāng)然不要忘了在.h里#impor<QuartzCore/QuartzCore.h>
列舉幾種
layer.cornerRadius = 5;
layer.masksToBounds = NO;
layer.borderWidth = .5;
layer.borderColor = [UIColor redColor].CGColor;
layer.shadowColor = [UIColor orangeColor].CGColor;
layer.shadowOpacity = 0.4;
layer.shadowRadius = 5.0;
iphone - can the border of UITextView or UILabel be set in storyboard? - Stack Overflow
上面鏈接里除了給出的上面的方法外,還有一種
IBInspectable?/ IBDesignable - NSHipster
這種我覺得更棒。有興趣的去學(xué)習(xí)吧。