在Objective-c,黑色视图中的IBInspectable和默认值

时间:2015-11-21 16:17:46

标签: ios objective-c ibinspectable

我在Objective-c项目中使用IBInspectables。我不想为这些设置一些默认值。这不是一个简单的方法,只需像在swift中那样设置一个默认值,所以我尝试在init方法中这样做:

@interface PushButtonView ()

@property (nonatomic, strong) IBInspectable UIColor *fillColor;
@property IBInspectable BOOL isAddButton;

@end

@implementation PushButtonView

-(instancetype)initWithCoder:(NSCoder *)aDecoder{

    self = [super initWithCoder:aDecoder];
    if(self){

        self.fillColor = [UIColor blueColor];
        self.isAddButton = YES;

    }

    return  self;
}

这允许我根据需要更改界面构建器中的值。但是,如果我选择default作为按钮的fillColor,它在界面构建器中显示为黑色而不是蓝色。我在这里做错了什么想法?任何指针都会很棒。

1 个答案:

答案 0 :(得分:0)

您无法更改默认颜色。因为UIButton上的这种颜色是黑色。你的按钮确实显示为黑色。

相关问题