Saturday, 13 September 2014

Jogendra Singh

How create UILabel programmatically in Swift?

       How create UILabel programmatically in Swift? 

       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;


  •        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 

Jogendra Singh

About Jogendra Singh -

I'm Founder of Jogendra.Com. I love to share my bright ideas with the whole blogging community. I'm a good iPhone Application Developer. Apart from Blogging, I love to play Cricket and mobile games (Clash of clans).

Subscribe to this Blog via Email :