Xcode8
更新好多新特性职祷,其中就增加了好多以前需要安裝插件才能實(shí)現(xiàn)的功能。如下文要說(shuō)到的 Color Literal
Image Literal
Documentation
都能找到對(duì)應(yīng)的插件届囚。
Color Literal
一般寫顏色大概是這樣的:
let color = UIColor(red: 100/255.0, green: 99/255.0, blue: 98/255.0, alpha: 1);
如果不? + R
有梆,我根本不知道這個(gè)顏色是什么。接下來(lái)使用 Color Literal 看看意系,如下圖泥耀,我要給 view 設(shè)置一個(gè)背景顏色,輸入 color literal 會(huì)有智能提示蛔添,回車痰催。
然后會(huì)彈出一個(gè)顏色選擇的界面:
可以選擇一個(gè)想要的顏色兜辞,還可以點(diǎn)擊下方的
Other
,選顏色蠟筆或者直接輸入顏色值夸溶。選完后在代碼里就會(huì)有個(gè)小方塊逸吵。里面填充的就是剛剛選的顏色。
Image Literal
如圖缝裁,我在資源庫(kù)有一張名為 defaultAvatar 的圖片:
傳統(tǒng)的寫法大概是這樣的:
let img = UIImage(named: "6")
與顏色很像扫皱,我要 ? + R
才能看見是不是想要的圖片。而且如果我把 key 寫錯(cuò)捷绑,圖片就不會(huì)顯示了韩脑。
輸入 image literal 出現(xiàn)智能提示,回車
出現(xiàn)一個(gè)圖片選擇器胎食,上面有圖片的縮略圖扰才。
Add Documentation
還有就是集成了VVDocumenter
, 使用? command + ? option + /
就可以添加好看的注釋了
/// <#Description#>
///
/// - parameter application: <#application description#>
/// - parameter launchOptions: <#launchOptions description#>
///
/// - returns: <#return value description#>
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}