我阅读了这篇文章IBInspectable / IBDesignable和流程步骤,但我发现更改没有立即呈现在情节提要上。有人知道为什么吗?我的 Xcode 版本:7.1
我的主要代码:
视图控制器.h
#import <UIKit/UIKit.h>
IB_DESIGNABLE
@interface ViewController : UIViewController
@end
UIView+CornerRadius.h
#import <UIKit/UIKit.h>
@interface UIView (CornerRadius)
@property(nonatomic ,assign) IBInspectable CGFloat cornerRadius;
@end
UIView+CornerRadius.m
#import "UIView+CornerRadius.h"
@implementation UIView (CornerRadius)
-(void)setCornerRadius:(CGFloat)cornerRadius {
self.layer.cornerRadius = cornerRadius;
self.layer.masksToBounds = cornerRadius > 0;
}
-(CGFloat)cornerRadius {
return self.layer.cornerRadius;
}
@end