Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/104.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios IBInspectable UIView属性_Ios_Uiview_Interface Builder_Ibdesignable - Fatal编程技术网

Ios IBInspectable UIView属性

Ios IBInspectable UIView属性,ios,uiview,interface-builder,ibdesignable,Ios,Uiview,Interface Builder,Ibdesignable,我可以让我的UIView@属性可检查吗 @interface Superview : UIView @property (nonatomic, weak, readonly) IBInspectable UIButton *stopButton; @property (nonatomic, weak, readonly) IBInspectable PKCircleProgressView *circleProgressView; @end 我创建了一个可设计视图PKCirc

我可以让我的UIView@属性可检查吗

@interface Superview : UIView 
    @property (nonatomic, weak, readonly) IBInspectable UIButton *stopButton;
    @property (nonatomic, weak, readonly) IBInspectable PKCircleProgressView *circleProgressView;
@end
我创建了一个可设计视图PKCircleProgressView,我希望它可以从IB中编辑。我还创建了另一个可设计视图,其中包含PKCircleProgressView作为子视图,我希望它也可以编辑

如果我在IB中使用Superview,有没有办法编辑circleProgressView的属性

我只有一个想法,为两个视图创建一个通用协议,并实现如下方法:

- (void)setProgress:(CGFloat)progress {
    self.circleProgressView.progress = progress;
}

但对每个属性都这样做并不容易,特别是如果我想创建另一个包含Superview的视图。

IBInspectable不支持UIView或其子类型。它支持简单的值

如果自定义进度视图是IBDesignable,为什么不将其属性(如半径和前景色)设置为IBInspectable,并在interface builder中选择进度视图并更改进度视图的属性

如果您创建了一个IBDesignable超级视图,那么您就可以使用类似于Decorator模式的方式公开它的按钮和进度视图的可检查属性


否您无法使UIView可检查。IBInspectable仅用于配置NIB或情节提要中实例的“键值”编码属性。 假设,如果UIView是键,那么它的值是什么?UIView没有值,因此无法使UIView可检查。 但我们可以使UIView的属性可检查,例如:

UIView的背景颜色、宽度、高度等

样本项目: