美文网首页
UIButton(按钮)

UIButton(按钮)

作者: Alan龙马 | 来源:发表于2017-05-11 14:36 被阅读19次
      lazy var deleBtn: UIButton = {
            
            let button = UIButton ()
            button.setTitle("删除", for: .normal)
            button.setTitleColor(UIColor.white, for: .normal)
            button.titleLabel?.font = UIFont.systemFont(ofSize: 15)
            button.backgroundColor = UIColor.red
            button.layer.borderColor = UIColor.black.cgColor
            button.layer.borderWidth = 0.5
            button.layer.cornerRadius = 3
            button.layer.masksToBounds = true
            button.addTarget(self, action: #selector(clickBtn1), for: .touchUpInside)
            
            return button
        }()
        
        @objc func clickBtn1(_ sender:UIButton)
        {
        }
    

    图片按钮

    lazy var Btn: UIButton = {
            
            let button = UIButton ()
            button.setImage(UIImage.init(named: "tab_service"), for: .normal)
            button.imageView?.contentMode = .scaleAspectFit
            button.setTitle("分享", for: .normal)
            button.addTarget(self, action: #selector(clickBtn), for: .touchUpInside)
    
            return button
        }()
    
    //按钮按下后的模糊状态
     button.adjustsImageWhenHighlighted = false  //使触摸模式下按钮也不会变暗(半透明)
     button.adjustsImageWhenDisabled=false //使禁用模式下按钮也不会变暗(半透明)
    
    ##禁用点击事件,一起用
    self.btnSelect.enabled = NO;
    self.btnSelect.adjustsImageWhenDisabled = NO;
    

    UIButton 用法
    http://www.hangge.com/blog/cache/detail_529.html
    https://www.jianshu.com/p/c69c72570285
    扩展UIButton
    http://www.hangge.com/blog/cache/detail_960.html
    https://www.jianshu.com/p/4676d84458f7
    自定义UIButton
    https://www.jianshu.com/p/f76b68440758

    ##图片文字按钮
    

    相关文章

      网友评论

          本文标题:UIButton(按钮)

          本文链接:https://www.haomeiwen.com/subject/pvlotxtx.html