美文网首页
Swift-代码实现基础UI组件

Swift-代码实现基础UI组件

作者: MadsSpec | 来源:发表于2015-12-08 11:03 被阅读0次

1.UIButton 通过IB实现就不记录了。

//声明

var MyButton:UIButton

//在viewDidLoad()中初始化控件,注意在设定组件属性是使用到的枚举。

MyButton = UIButton.buttonWithType(UIButtonType.Syetem) as! Button

MyButton.setTitle("注册",forState:  UIControlState.Normal)

MyButton.setImage(UIIamge(name: "1.jpg"),forState:UIControlState.Normal)

MyButton.frame = CGRect(x: 10, y: 30, width: 100, height:40)

MyButton.addTarget(self,action:"Click:",forControlEvents: UIControlEvents.TouchUpInside)

self.view,addSubview(self.MyButton)

//定义addTarget中设定的方法

func Click(sender:UIButton){ println("OnClick") }

相关文章

网友评论

      本文标题:Swift-代码实现基础UI组件

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