• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

swift code

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
Functions

Init(object, setup) - initializer pattern.
var view = Init(UIView) {[unowned self] in
    $0.backgroundColor = UIColor.whiteColor();
    self.view.addSubview($0)
}

  https://github.com/ivabra/IBSwiftToolKit/tree/6ad06dc794119d3c7fa8d72f2328239261f8034b

extension UILabel {
    func getBlock(block:(make:UILabel) -> Void) -> Void {
        let label = self
        block(make:label)
        
    }
    /// 快速创建一个UILabel
    class func getLabel(block:(make:UILabel) -> Void) -> UILabel
    {
        let label = UILabel()
        block(make:label)
        return label
    }
}

        eventDescriptionPlaceholderLabel.getBlock(){ (make) in
            make.text = "Description (Optional)"
            make.font = UIFont(name: "Helvetica", size: 17)
            make.sizeToFit()
            make.userInteractionEnabled = false
            
            make.frame.origin = CGPointMake(0, 0)
            make.textColor = ColorFromCode.colorWithHexString("#BEBEBE")
            
        }
        eventDescriptionPlaceholderLabel = UILabel.getLabel({ (make) in
            make.text = "Description (Optional)"
            make.font = UIFont(name: "Helvetica", size: 17)
            make.sizeToFit()
            make.userInteractionEnabled = false
            
            make.frame.origin = CGPointMake(0, 0)
            make.textColor = ColorFromCode.colorWithHexString("#BEBEBE")
        })

  

 

class Tool {
    /// 快速创建一个UILabel
    class func getLabel(@noescape block:(ws:UILabel) -> Void) -> UILabel
    {
        let label = UILabel()
        block(ws:label)
        return label
    }
    
    class func getView(@noescape block:(ws:UIView) -> Void) -> UIView
    {
        let view = UIView()
        block(ws:view)
        return view
    }
    class func getImageView(@noescape block:(ws:UIImageView) -> Void) -> UIImageView
    {
        let view = UIImageView()
        block(ws:view)
        return view
    }
    class func getButton(@noescape block:(ws:UIButton) -> Void) -> UIButton
    {
        let view = UIButton()
        block(ws:view)
        return view
    }
    
}

 

 

extension UILabel {
    override func getBlock(@noescape block:(ws:UILabel) -> Void) -> Void {
        let label = self
        block(ws:label)
        
    }
    /// 快速创建一个UILabel
    class func getLabel(@noescape block:(ws:UILabel) -> Void) -> UILabel
    {
        let label = UILabel()
        block(ws:label)
        return label
    }
}

extension UIButton {
    override func getBlock(@noescape block:(ws:UIButton) -> Void) -> Void {
        let button = self
        block(ws:button)
        
    }
}

extension UIImageView {
    override func getBlock(@noescape block:(ws:UIImageView) -> Void) -> Void {
        let view = self
        block(ws:view)
        
    }
}

extension UIView {
    func getBlock(@noescape block:(ws:UIView) -> Void) -> Void {
        let view = self
        block(ws:view)
        
    }
}

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
SwiftLint——Swift代码检查及自动格式化工具发布时间:2022-07-13
下一篇:
Swift编码总结3 - 玉思盈蝶发布时间:2022-07-13
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap