How create UILabel programmatically in Swift?
How can I create
Thanks for visit here, leave you feedback here
How can I create
UILabel
programmatically using Swift language in Xcode 6? I create a new project in Xcode 6 and select Swift language for this project.
var label = UILabel(frame: CGRectMake(5, 100, 200, 50 ))
label.textAlignment = NSTextAlignment.Center
label.backgroundColor = UIColor.redColor()
label.text = "hello";
label.tag = 5;
self.view.addSubview(label);
- Access label value using tag value of label.
var theLabel : UILabel = self.view.viewWithTag(5) as UILabel
// here accessing label using tag value
theLabel.text = "working fine"
Thanks for visit here, leave you feedback here