美文网首页
swift view &button 创建

swift view &button 创建

作者: 胖红Red | 来源:发表于2018-03-20 11:52 被阅读4次
    let screenh = UIScreen.main.applicationFrame.size.height
    let screenw = UIScreen.main.applicationFrame.size.width
    
    let vFooter:UIView = UIView()
    
    vFooter.frame = CGRect(x:0, y:screenh-74-44, width:screenw, height:74)
    vFooter.backgroundColor = UIColor.clear
    self.view.addSubview(vFooter)
    
    
    let btnApply:UIButton = UIButton(type:.custom)
    btnApply.frame = CGRect(x:30, y:15, width:screenw-60, height:44)
    btnApply.setTitle("立即申请", for: UIControlState.normal)
    btnApply.layer.masksToBounds = true
    btnApply.layer.cornerRadius = btnApply.frame.size.height/2
    btnApply.setTitleColor(UIColor.white, for: UIControlState.normal)
    btnApply.backgroundColor = UIColor(red: CGFloat(44)/255.0, green: CGFloat(154)/255.0, blue: CGFloat(255)/255.0, alpha: 1)
    btnApply.addTarget(self, action:#selector(clickBtnApply(_:)), for: .touchUpInside)
    vFooter.addSubview(btnApply)

按钮的点击事件

func clickBtnApply(_ sender: Any) {
     
}

相关文章

网友评论

      本文标题:swift view &button 创建

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