【问题标题】:IB_DESIGNABLE and IBINSTECTABLE UIImageViewIB_DESIGNABLE 和 IBINSTECTABLE UIImageView
【发布时间】:2017-11-25 15:45:06
【问题描述】:

我正在尝试向我的 UIImageView 子类添加自定义属性。属性类型为 UIImageView。我在其他数据类型、UIColor、int 等方面取得了成功。但 UIImageView 只是没有出现在界面构建器的自定义字段中,我无法通过代码访问它。

#import <UIKit/UIKit.h>


IB_DESIGNABLE
@interface newLayerController : UIImageView

@property (nonatomic, copy) IBInspectable UIImageView *imageSheet;

  - (void)drawShape:(CGPoint)point;
  - (void)endTouch:(CGPoint)point;
  - (void)startTouch:(CGPoint)point;

@end

有人知道快速解决方法吗?

【问题讨论】:

  • 你不能有 ibinspectable uiimageview。但是,您可以拥有 @property (nonatomic, copy) IBInspectable UIImage* 图像;在您的代码中,您可以将其分配给视图。

标签: ios objective-c ibdesignable ibinspectable


【解决方案1】:

使用 UIImage 代替 UIImageView。

@IBInspectable var backImage: UIImage = UIImage() {
    didSet{
        setbackImage()
    }
}

func setbackImage(){ self.image = backImage}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-28
    • 2018-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-02
    相关资源
    最近更新 更多