IBInspectable UIView Property
Can UIView @property be customized?
@interface Superview : UIView
@property (nonatomic, weak, readonly) IBInspectable UIButton *stopButton;
@property (nonatomic, weak, readonly) IBInspectable PKCircleProgressView *circleProgressView;
@end
I have created a PKCircleProgressView design and I want it to be editable from IB. Also I created another friendly view which contains PKCircleProgressView as subview and I want it to be editable as well.
Is there a way to edit the properties of the circleProgressView if I am using Superview in IB?
I came out with just one idea to create a common protocol for both views and implement methods like:
- (void)setProgress:(CGFloat)progress {
self.circleProgressView.progress = progress;
}
but it's not easy to do with every property, especially if I want to create another view containing my Superview.
source to share
IBInspectable does not support UIView or its subtypes. It supports simple values.
If your custom progress view is IBDesignable, why not set its properties like the radius and foreground color to IBInspectable and in the UI builder select the progress view and change the progress view properties?
If you are building an IBDesignable add-in, you can open the checked properties of that button and see the progress using something like the Decorator pattern.
source to share
No, you cannot make UIView Inspectable. The use of IBInspectable is only for setting the coded property "key value" of an instance in the NIB or storyboard. Suppose if UIView becomes a key then what is its value? There will be no value for UIView, so you cannot make UIView Inspectable. But we can make UIView Inspectable attributes like:
UIView backgroundColor, width, height, etc.
Sample Project: IBDesignable and IBInspectable
source to share