本章為第一章,后續每兩天會有持續更新, ,錯誤部分 希望大家來抨擊及更正.
UILabel的創建及常用屬性
///創建UILabel 設置坐標格式 CGRect(x: 0,y: 200,width: 100,height: 40)
let label = UILabel(frame:CGRect(x: 0,y: 200,width: 200,height: 100))
///設置label的背景顏色
label.backgroundColor = UIColor.red
///給label賦值
label.text = "字體大小";
///設置字體顏色
label.textColor = UIColor.purple
///設置字體對齊方式
label.textAlignment = NSTextAlignment.center
///設置字體陰影顏色
label.shadowColor = UIColor.yellow
///設置Label陰影偏移位置
label.shadowOffset = CGSize(width:20,height:20)
///設置Label多行顯示
label.numberOfLines = 0
///設置Label文本高亮
label.isHighlighted = true
///設置Label文本顏色高亮
label.highlightedTextColor = UIColor.green
///設置Label圓角屬性
label.layer.masksToBounds = true
///設置Label圓角半徑
label.layer.cornerRadius = 4
///設置Label邊框
label.layer.borderWidth = 1
///設置Label邊框顏色
label.layer.borderColor = UIColor.yellow.cgColor
///設置Label字體大小
label.font = UIFont.systemFont(ofSize: 15)
///設置Label字體時同時設置大小
label.font = UIFont(name:"字體大小",size:25)
///將Label加入父視圖中
self.view .addSubview(label)