我正在阅读这篇文章IBInspectable / IBDesignable和流程步骤,但我发现更改没有立即在故事板上呈现。任何人都知道为什么? 我的Xcode版本:7.1
我的主要代码:
ViewController.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