Created
October 23, 2014 06:58
-
-
Save MaxCloud83/98b29bcb424cfad4b8f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // UIKit001ViewController.swift | |
| // | |
| import UIKit | |
| class UIKit001ViewController: UIViewController { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| // new UILabel. | |
| let uiLabel: UILabel = UILabel(frame: CGRectMake(0,0,200,50)) | |
| // 设置 Label 的背景色为 black. | |
| uiLabel.backgroundColor = UIColor.blackColor() | |
| // 设置圆角属性. | |
| uiLabel.layer.masksToBounds = true | |
| // 设置边角弧度半径. | |
| uiLabel.layer.cornerRadius = 20.0 | |
| // 设置 Label 文字列. | |
| uiLabel.text = "Hello Swift!!" | |
| // 设置文字的颜色为 white. | |
| uiLabel.textColor = UIColor.whiteColor() | |
| // 设置文字 shadow 的颜色为 gray. | |
| uiLabel.shadowColor = UIColor.grayColor() | |
| // 设置文字为中央对齐. | |
| uiLabel.textAlignment = NSTextAlignment.Center | |
| // 设置 Label 的坐标. | |
| uiLabel.layer.position = CGPoint(x: self.view.bounds.width/2,y: 200) | |
| // 设置 View 的背景色为 cyan. | |
| self.view.backgroundColor = UIColor.cyanColor() | |
| // 将 Label 追加进 View | |
| self.view.addSubview(uiLabel) | |
| } | |
| override func didReceiveMemoryWarning() { | |
| super.didReceiveMemoryWarning() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment