Tag: ibinspectable

如何在Objective-C中设置IBInspectable的默认值?

我知道IBInspectable-properties的默认值可以设置为: 在Swift中@IBInspectable var propertyName:propertyType = defaultValue 。 但是如何在Objective-C中实现类似的效果,以便我可以将某些属性的默认值设置为Interface Builder中的某些属性?

IB_DESIGNABLE,IBInspectable – 接口生成器不更新

我有以下一组代码: CustomView.h #import <UIKit/UIKit.h> IB_DESIGNABLE @interface CustomView : UIView @property (nonatomic) IBInspectable UIColor *borderColor; @property (nonatomic) IBInspectable CGFloat borderWidth; @property (nonatomic) IBInspectable CGFloat cornerRadius; @end CustomView.m #import "CustomView.h" @implementation CustomView – (void)setBorderColor:(UIColor *)borderColor { _borderColor = borderColor; self.layer.borderColor = borderColor.CGColor; } – (void)setBorderWidth:(CGFloat)borderWidth { _borderWidth = borderWidth; self.layer.borderWidth = borderWidth; } – (void)setCornerRadius:(CGFloat)cornerRadius { _cornerRadius […]

@IBDesignable错误:IB Designables:无法更新自动布局状态:Interface Builder Cocoa Touch Tool崩溃

我有一个非常简单的UITextView的子类,它添加了可以在Text Field对象中find的“占位符”function。 这是我的子类的代码: import UIKit import Foundation @IBDesignable class PlaceholderTextView: UITextView, UITextViewDelegate { @IBInspectable var placeholder: String = "" { didSet { setPlaceholderText() } } private let placeholderColor: UIColor = UIColor.lightGrayColor() private var textColorCache: UIColor! override init(frame: CGRect) { super.init(frame: frame) self.delegate = self } required init(coder aDecoder: NSCoder) { super.init(coder: aDecoder) self.delegate = self […]