Reputation: 9076
I have created a class category in Objective C:
#import <UIKit/UIKit.h>
@interface UIView (LayerProperties)
@property IBInspectable (nonatomic) CGFloat cornerRadius;
@property IBInspectable (nonatomic) CGFloat borderWidth;
@property IBInspectable (nonatomic, strong) UIColor *borderColour;
@end
This is all good and works if I import the header. How do I get this category to show up in Interface Builder when I add a UIView?
Upvotes: 2
Views: 767
Reputation: 9076
I was being dumb. All that is wrong is that I have put the IBInspectable macro in the wrong place in my property definition:
@property IBInspectable (nonatomic) CGFloat cornerRadius;
Should be:
@property (nonatomic) IBInspectable CGFloat cornerRadius;
Silly mistake, might help someone else save some time. Now all properties show up on all views (and view subclasses):
Upvotes: 2
Reputation: 127
Try this. KVC in interface builder. Maybe you need subclass
Or Create subclass and use IBInspectable / IBDesignable
(http://nshipster.com/ibinspectable-ibdesignable/ )
Upvotes: 2
Reputation: 27052
You need to subclass a view where you should import this category. And then change your storyboard view with that subclassed view, all the properties from your category should be available then.
For e.g.
#import "LayerProperties+UIView.h"
@interface MyCustomView : UIView
@end
Now in IB, change your view class to MyCustomView
.
Upvotes: 0