IB_DESIGNABLE 未在情节提要中呈现

IB_DESIGNABLE Is not rendering in storyboard

#import "UIViewTest.h"

@implementation UIViewTest

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/


- (id) initWithCoder:(NSCoder *)coder{
    self = [super initWithCoder:coder];
    if(self){
        self.backgroundColor = UIColor.redColor;
    }
    
    return self;
    
}

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    
    if(self){
        self.backgroundColor = UIColor.redColor;
    }
    
    return self;
}

@end

我有这段代码可以在设备上运行,但在 IB 中似乎不起作用,

IB_DESIGNABLE @interface  UIViewTest : UIView
@end

我尝试将目标设置为继承,尝试指定模块但似乎没有任何效果。

实施prepareForInterfaceBuilder:

- (void)prepareForInterfaceBuilder {
    self.backgroundColor = UIColor.redColor;
}

(如果重复困扰您,重构。)