zoukankan      html  css  js  c++  java
  • 在Attribute Inspector 上显示自定义的控件的属性

    FirstColor 跟 CornerRadious 都是新增的显示属性具体实现方法如下:

    @property(nonatomic,weak)IBInspectable UIColor *firstColor;

    /...................................../

    - (void)setFirstColor:(UIColor *)firstColor{

        _firstColor = firstColor;

         self.backgroundColor = firstColor;

    }

    在定义的属性面前增加IBInspectable关键字 (视图已经拖到控制器上)

    如果想让所有的View的某个属性都能在IB上显示的话可以新建View的category

    @interface UIView (IBIspectable)

    @property(nonatomic,assign)IBInspectable CGFloat cornerRadious;

    /............在implementation添加IB_DESIGNABLE关键字........................./

    IB_DESIGNABLE

    @implementation UIView (IBIspectable)

    - (void)setCornerRadious:(CGFloat)cornerRadious{

        self.layer.cornerRadius = cornerRadious;

        self.layer.masksToBounds = cornerRadious>0;

    }

    - (CGFloat)cornerRadious{

         return self.layer.cornerRadius;

    }

  • 相关阅读:
    cf #363 c
    cf #363 b
    cf #363 a
    跑rbgirshick的fast-rcnn代码
    改文件夹名称
    cmake安装
    argparse模块
    which,whereis,locate,find
    FastRCNN 训练自己数据集 (1编译配置)
    视觉一般的面试问题
  • 原文地址:https://www.cnblogs.com/cnman/p/5224206.html
Copyright © 2011-2022 走看看