hello friends,
this is how we can create a UIButton and UILabel in swift.
Set a UILabel in swift
var label = UILabel(frame: CGRectMake(100, 100, self.view.bounds.size.width, 50))
label.center = self.view.center
label.textAlignment = NSTextAlignment.Center
label.text = test label
label.textColor = UIColor.grayColor()
self.view.addSubview(label)
Set a UIButton in swift
let testButton = UIButton.buttonWithType(UIButtonType.System) as! UIButton
testButton.backgroundColor = UIColor.orangeColor()
testButton .setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal)
testButton.setTitle(click here, forState: UIControlState.Normal)
testButton.frame = CGRectMake(self.view.bounds.size.width,100, 100, 50)
testButton.addTarget(self, action: "buttonClicked:, forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(testButton)
0 Comment(s)