只有使用Storyboard時(shí)才自動(dòng)調(diào)用:
override func awakeFromNib() {
print("從Storyboard中加載")
}
imageView
- 設(shè)斷點(diǎn),查看是否加載了圖片
- 如果圖片沒有被加載
項(xiàng)目中沒有該圖片
目標(biāo)文件沒有更新,Product --> Clean
//為普通狀態(tài)設(shè)置圖片
let img = UIImage(named: "cm2_play_icn_loved")
imageView123.image = img
//為高亮狀態(tài)設(shè)置圖片
let hImg = UIImage(named: "cm2_rcd_btn_back")
imageView123.highlightedImage = hImg
//設(shè)置高亮狀態(tài)為真
imageView123.highlighted = true
//圖片的填充模式(拉伸模式)
imageView123.contentMode = .ScaleAspectFit
- 設(shè)置動(dòng)態(tài)圖
//將圖片的名字放到數(shù)組中
let imgNames = ["cm2_play_icn_loved", "cm2_rcd_btn_back", "cm2_rcd_btn_forward"]
//根據(jù)名字拿出圖片
let imgs = imgNames.map({
return UIImage(named: $0)!
})
//默認(rèn)1/30
//表示動(dòng)畫執(zhí)行一周所花的時(shí)間
imageView123.animationDuration = 3
//正常狀態(tài)下的動(dòng)畫數(shù)組
imageView123.animationImages = imgs
//動(dòng)畫重復(fù)次數(shù)
imageView123.animationRepeatCount = 2
//啟動(dòng)動(dòng)畫
imageView123.startAnimating()
label
//0-1: 黑-白
label.textColor = UIColor(white: 0.0, alpha: 1.0)
//字體顏色
label.textColor = UIColor(red: 1.0, green: 1.0, blue: 0.0, alpha: 1.0)
//字體大小
label.font = UIFont.systemFontOfSize(24)
//水平對齊方式
label.textAlignment = .Center
//設(shè)置為0,自動(dòng)計(jì)算行數(shù)
label.numberOfLines = 0
//換行模式:通過刪除中間
label.lineBreakMode = .ByTruncatingMiddle
//設(shè)置字體
label.font = UIFont(name: "PingFangSC-Semibold", size: 32)
//打印系統(tǒng)的字體
print(UIFont.familyNames())
for family in UIFont.familyNames() {
for font in UIFont.fontNamesForFamilyName(family) {
print(family, ":", font)
}
}
progress
//左側(cè)的顏色
progressView.progressTintColor = UIColor.blueColor()
//右側(cè)的顏色
progressView.trackTintColor = UIColor.brownColor()