Xcode8
更新好多新特性,其中就增加了好多以前需要安裝插件才能實(shí)現(xiàn)的功能。如下文要說到的 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è)顏色是什么。接下來使用 Color Literal 看看,如下圖,我要給 view 設(shè)置一個(gè)背景顏色,輸入 color literal 會(huì)有智能提示,回車。
然后會(huì)彈出一個(gè)顏色選擇的界面:
可以選擇一個(gè)想要的顏色,還可以點(diǎn)擊下方的
Other
,選顏色蠟筆或者直接輸入顏色值。選完后在代碼里就會(huì)有個(gè)小方塊。里面填充的就是剛剛選的顏色。
Image Literal
如圖,我在資源庫有一張名為 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
}