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;

    }

  • 相关阅读:
    聊一聊Flutter的setState()
    Flutter + Android 混合开发
    Flutter防止布局溢出
    Flutter获取远程数据 刷新UI界面
    Flutter日常笔记
    POJ 3299 Humidex
    POJ 1207 The 3n + 1 problem
    POJ 1005 I Think I Need a Houseboat
    POJ 1004 Financial Management
    POJ1012
  • 原文地址:https://www.cnblogs.com/cnman/p/5224206.html
Copyright © 2011-2022 走看看