当我将图像设置为 IBImageView 时,构建失败

When I set the image to IBImageView, get build failed

我的 IBImageView 是这样的:

LMLCommonIBImageView.h中:

#import <UIKit/UIKit.h>

IB_DESIGNABLE
@interface LMLCommonIBImageView : UIImageView

@property (nonatomic, assign)IBInspectable CGFloat borderWidth;
@property (nonatomic, strong)IBInspectable UIColor *borderColor;

@property (nonatomic, assign)IBInspectable CGFloat cornerRadius;

@end

LMLCommonIBImageView.m 文件中:

#import "LMLCommonIBImageView.h"

@implementation LMLCommonIBImageView


- (void)setBorderWidth:(CGFloat)borderWidth {

    if (borderWidth < 0) return;

    self.layer.borderWidth = borderWidth;
}

- (void)setBorderColor:(UIColor *)borderColor {

    self.layer.borderColor = borderColor.CGColor;
}


- (void)setCornerRadius:(CGFloat)cornerRadius {

    self.layer.cornerRadius = cornerRadius;
    self.layer.masksToBounds = cornerRadius > 0;
}

我收到这个错误:

IBDesignables Build failed

试试这个

  1. 清理项目。
  2. 然后在情节提要中转到“编辑器”菜单并执行“刷新所有视图”;等待构建完成。