Xcode學(xué)習(xí)文檔:Xcode4主題樣式
本文主要是來學(xué)習(xí)Xcode的學(xué)習(xí)文檔,來了解并學(xué)習(xí)Xcode4主題樣式的操作的內(nèi)容,詳細(xì)的獎金了整個過程類似實現(xiàn)xcode4的主題樣式,具體內(nèi)容來看本文詳細(xì)內(nèi)容。
一、下載安裝Xcode4
因為我需要讓Xcode4和老版本共存,在安裝Xcode4時選擇其他安裝路徑,安裝成功后在xcode4安裝目錄下改名Xcode.app為Xcode4.app以區(qū)分老版本,隨便找一個xcodeproj文件,右鍵Get Info,在Open with里面選擇Xcode4并點擊Change All以設(shè)置文件類型關(guān)聯(lián)。
二、熟悉界面
打開Xcode,大概瀏覽下界面的變化,到處亂點下看是啥東西,把Xcode菜單瀏覽一遍。有空的話可以看看幫助文檔里面關(guān)于源代碼管理的部分。試著建一個HelloWorld項目,并操作下IB鏈接。
三、配置代碼編輯器的字體和顏色(Fonts & Colors)
我比較喜歡用黑色背景寫代碼,眼睛比較舒服。以前老的ColorTheme文件用不了,ColorTheme的存放路徑變了,舊的在~/Library/Application Support/Xcode/Color Themes,Xcode4的在~/Library/Developer/Xcode/UserData/FontAndColorThemes下,而且文件格式也變了,但是大部分項目都是一樣的??梢灾匦屡渲妙伾煮w,也可以對照著手動改配置文件。
Google了一下,aktowns已經(jīng)寫了一個轉(zhuǎn)換腳本:https://gist.github.com/793006
使用方法非常簡單:
1、下載dvtcolorconvert.rb,假如你放在桌面,把舊的Theme文件也復(fù)制到桌面
- //dvtcolorconvert.rb
- #!/usr/bin/env ruby
- # This script converts xccolorthemes to dtvcolorthemes for porting xcode 3.x themes to xcode 4.x
- # created by ashley towns <ashleyis@me.com>
- # Public domain.
- # ./dvtcolorconvert <inputfile>
- # spits out a .dtvcolortheme file
- require 'rubygems'
- require 'plist'
- raise "Error: need a source file #{__FILE__} [file.xccolortheme]" if ARGV.length == 0
- def alpha inc, alpha=1
- "#{inc} #{alpha}"
- end
- def convert infile
- hash = Plist::parse_xml infile
- out_hash = {}
- out_hash[:DVTSourceTextSyntaxFonts] = {}
- out_hash[:DVTSourceTextSyntaxColors] = {}
- hash.each do |name, node|
- node.each do |child_name, child|
- puts "[on] node:#{name} child:#{child_name}(#{child})"
- if name == "Colors"
- case child_name
- when /Background/
- out_hash[:DVTSourceTextBackground] = alpha child
- out_hash[:DVTConsoleTextBackgroundColor] = alpha child
- out_hash[:DVTSourceTextInvisiblesColor] = alpha child
- out_hash[:DVTSourceTextBlockDimBackgroundColor] = alpha child
- when /InsertionPoint/
- out_hash[:DVTSourceTextInsertionPointColor] = alpha child
- out_hash[:DVTConsoleTextInsertionPointColor] = alpha child
- out_hash[:DVTDebuggerInsutrctionPointerColor] = alpha child
- out_hash[:DVTConsoleDebuggerInputTextColor] = alpha child
- out_hash[:DVTConsoleDebuggerOutputTextColor] = alpha child
- out_hash[:DVTConsoleExectuableInputTextColor] = alpha child
- out_hash[:DVTConsoleExecutableOutputTextColor] = alpha child
- when /Selection/
- out_hash[:DVTSourceTextSelectionColor] = alpha child
- out_hash[:DVTConsoleTextSelectionColor] = alpha child
- out_hash[:DVTDebuggerPromptTextColor] = alpha child
- else
- out_hash[:DVTSourceTextSyntaxColors][child_name] = alpha child
- end
- elsif name == "Fonts"
- case child_name
- when /xcode.syntax.plain/
- child = "Inconsolata - 14pt"
- out_hash[:DVTConsoleDebuggerInputTextFont] = child
- out_hash[:DVTConsoleDebuggerOutputTextFont] = child
- out_hash[:DVTConsoleDebuggerPromptTextFont] = child
- out_hash[:DVTConsoleExecutableInputTextFont] = child
- out_hash[:DVTConsoleExecutableOutputTextFont] = child
- out_hash[:DVTSourceTextSyntaxFonts]['xcode.syntax.plain'] = child
- else
- out_hash[:DVTSourceTextSyntaxFonts][child_name] = "Inconsolata - 14pt" #child
- end
- else
- raise "I don't know what #{name} is."
- end
- end
- end
- puts "Saving #{infile.gsub(/xccolortheme/,'dvtcolortheme')}"
- fp = File.open(infile.gsub(/xccolortheme/,'dvtcolortheme'),'w')
- fp.write out_hash.to_plist
- fp.close
- end
- convert ARGV[0]
- #Dir['*.xccolortheme'].each do |file|
- # convert file
- #end
2、安裝"plist“ ruby gem: $sudo gem install plist
3、執(zhí)行轉(zhuǎn)化: $ruby dvtcolorconvert.rb ElfDart.xccolortheme 就在桌面生成ElfDart.xccolortheme了,放到~/Library/Developer/Xcode/UserData/FontAndColorThemes下重啟Xcode4,在Preferences中的Fonts & Colors啟用主題。
我轉(zhuǎn)換后的主題文件,如圖:
如果你喜歡的話可以在這里下載到:http://code.google.com/p/elf-ios-resource/downloads/detail?name=ElfDark.dvtcolortheme
https://github.com/Sundae/Cocoa-Utilities
四、Preferences/Text Editing (圖示)
小結(jié):Xcode學(xué)習(xí)文檔:Xcode4主題樣式的內(nèi)容介紹完了,希望通過本文的學(xué)習(xí)能對你有所幫助!