import UIKit
class ViewController: UIViewController {
//这里做个lab声明
var exampleLab : UILabel!
override func viewDidLoad() {
super.viewDidLoad()
//调用makeUI
makeUI()
// Do any additional setup after loading the view, typically from a nib.
}
//写一个方法哦
private func makeUI() {
//初始化lab
self.exampleLab = UILabel.init()
//給他frame
self.exampleLab.frame = CGRectMake(100, 100, 200, 40)
//lab 赋值
self.exampleLab.text = "我仅仅是一个lab我仅仅是一个lab我仅仅是一个lab我仅仅是一个lab"
//设置lab居中
self.exampleLab.textAlignment = .Center
//设置lab 字体大小
self.exampleLab.font = UIFont.systemFontOfSize(13)
//设置lab的字体颜色
self.exampleLab.textColor = UIColor(red: 12/255.0, green: 122/255.0, blue: 222/255.0, alpha: 1)
//设置lab 的背景颜色
self.exampleLab.backgroundColor = UIColor.blackColor()
//給lab 添加圆角(角度为lab 高度的一半的时候会是半圆)
self.exampleLab.layer.cornerRadius = 20
//多余的部分切掉
self.exampleLab.clipsToBounds = true
//设置lab 的字体阴影颜色
//self.exampleLab.shadowColor = UIColor.redColor()
//设置阴影偏移
//self.exampleLab.shadowOffset = CGSizeMake(1, 1)
//设置lab 的分行
self.exampleLab.numberOfLines = 0
//添加lab 到view上
self.view .addSubview(self.exampleLab)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}