關(guān)于Swift 3.X UI部分的創(chuàng)建及屬性

本章為第一章,后續(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)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容