A Quick start with Swift


1.Create UILabel in Swift programmatically

var textLabel=UILabel(frame: CGRectMake(15, 5, self.view.frame.size.width-30, 40))

        textLabel.text=tableArray[indexPath.row];

        textLabel.textColor=UIColor.blueColor()

        textLabel.textAlignment=NSTextAlignment.Center

        cell.addSubview(textLabel)


2. Add border using Swift

textLabel.layer.borderColor=UIColor.orangeColor().CGColor

textLabel.layer.borderWidth=2.0


3. Move form one Window to Another window using Swift

let challengeTable = self.storyboard?.instantiateViewControllerWithIdentifier(“challangeTable”)as ChallengeTable

            

            self.navigationController?.pushViewController(challengeTable, animated: true)

— – – where challangeTable is identifier id and ChallengeTable is Swift class


4. UIButton using Swift

var cancelButton=UIButton(frame: CGRectMake(self.view.frame.size.width30, 0, 30, 30))

        cancelButton.titleLabel?.text=“X”

        cancelButton.titleLabel?.textColor=UIColor.whiteColor()

        cancelButton.backgroundColor=UIColor.blackColor()

        self.view.addSubview(cancelButton)


5. WebView using Swift

var htmlRequest=NSURLRequest(URL:NSURL(string: https://eriphonedevelopers.wordpress.com/”))

        

        var webView=UIWebView(frame: CGRectMake(15, 15, screenWidth30, screenHeight116))

        webView.loadRequest(htmlRequest)

        tocView.addSubview(webView)


6. Getting Screen size in Swift

var screenWidth=UIScreen.mainScreen().bounds.width

        var screenHeight=UIScreen.mainScreen().bounds.height

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: