非常简单,没什么好说的,直接上代码吧;
#import <UIKit/UIKit.h>
IB_DESIGNABLE
@interface RBButton : UIButton
@property (assign, nonatomic) IBInspectable CGFloat borderWidth;
@property (strong, nonatomic) IBInspectable UIColor *borderColor;
@property (assign, nonatomic) IBInspectable CGFloat cornerRadius;
@end
#import "RBButton.h"
@implementation RBButton
- (void)setBorderColor:(UIColor *)borderColor {
self.layer.masksToBounds = YES;
self.layer.borderColor = borderColor.CGColor;
}
- (void)setBorderWidth:(CGFloat)borderWidth {
self.layer.masksToBounds = YES;
self.layer.borderWidth = borderWidth;
}
- (void)setCornerRadius:(CGFloat)cornerRadius {
self.layer.masksToBounds = YES;
self.layer.cornerRadius = cornerRadius;
}
@end
然后->
快去试试效果吧。
参考文档:https://developer.apple.com/library/ios/recipes/xcode_help-IB_objects_...
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。