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