[Xcode] Attributes Inspector 界面自定义实时渲染属性

在工程里面新建文件 Cocoa Touch Class  模版选对应的 比如 对 ImageView 扩展 就创建UIImageView 这个对应的类可以在 Identity Inspector 里面看默认的类名字

import UIKit

@IBDesignable // 添加这个实现StoryBoard实时渲染结果
class addAttributes: UIImageView {
   
    @IBInspectable var cornerRadius: CGFloat = 0 { // @IBInspectable 可以在Attributes 界面上显示
        didSet {
            layer.cornerRadius = cornerRadius // 圆角的设置
            layer.masksToBounds = cornerRadius > 0  // 负值为否
            
        }
    }
}

 

效果如下示 

posted @ 2015-08-12 20:28  baaingSheep  阅读(600)  评论(0编辑  收藏  举报