Search code examples
iosstoryboardibdesignable

When I set the image to IBImageView, get build failed


My IBImageView is like this:

In 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

In LMLCommonIBImageView.m file:

#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;
}

I get this error:

IBDesignables Build failed

enter image description here


Solution

  • Try this

    1. clean project .
    2. then In storyboard go to Editor menu and do Refresh All Views; wait for build to be completed .