复制.h文件
//
// UIView+GS.h
// refresh
//
// Created by apple on 16/6/1.
// Copyright © 2016年 apple. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIView (GS)
@property (nonatomic, assign)IBInspectable CGFloat cornerRadius;
@property (nonatomic, assign)IBInspectable CGFloat borderWidth;
@property (nonatomic, strong)IBInspectable UIColor *borderColor;
@end
复制.m文件
//
// UIView+GS.m
// refresh
//
// Created by apple on 16/6/1.
// Copyright © 2016年 apple. All rights reserved.
//
#import "UIView+GS.h"
#import <objc/runtime.h>
@implementation UIView (GS)
- (UIColor *)borderColor
{
return objc_getAssociatedObject(self, @selector(borderColor));
}
- (void)setBorderColor:(UIColor *)borderColor
{
self.layer.borderColor = borderColor.CGColor;
}
- (CGFloat)cornerRadius
{
return [objc_getAssociatedObject(self, @selector(cornerRadius)) floatValue];
}
- (void)setCornerRadius:(CGFloat)cornerRadius
{
self.layer.cornerRadius = cornerRadius;
self.layer.masksToBounds = YES;
}
- (CGFloat)borderWidth
{
return [objc_getAssociatedObject(self, @selector(borderWidth)) floatValue];
}
- (void)setBorderWidth:(CGFloat)borderWidth
{
self.layer.borderWidth = borderWidth;
self.layer.masksToBounds = YES;
}
@end