前兩天在網(wǎng)上看到了大神介紹如何在xib中設(shè)置view圓角委可,我把代碼貼出來价卤,so easy??
新建view的分類 UIView+CornerRadius
.h?
@interfaceUIView (CornerRadius)
/** cornerRadius */
// 寫上這個(gè)關(guān)鍵字 IBInspectable礼华,就可以在xib中看到了
@property(nonatomic,assign) IBInspectable CGFloat cornerRadius;
@end
.m
#import"UIView+CornerRadius.h"
@implementationUIView (CornerRadius)
- (void)setCornerRadius:(CGFloat)cornerRadius
{
self.layer.cornerRadius= cornerRadius;
self.layer.masksToBounds= cornerRadius >0;
}
- (CGFloat)cornerRadius
{
returnself.layer.cornerRadius;
}
@end