Xcode學習文檔:Xcode4主題樣式

來源:互聯網
上載者:User

本文主要是來學習Xcode的學習文檔,來瞭解並學習Xcode4主題樣式的操作的內容,詳細的獎金了整個過程類似實現xcode4的主題樣式,具體內容來看本文詳細內容。

一、下載安裝Xcode4

因為我需要讓Xcode4和老版本共存,在安裝Xcode4時選擇其他安裝路徑,安裝成功後在xcode4安裝目錄下改名Xcode.app為Xcode4.app以區分老版本,隨便找一個xcodeproj檔案,右鍵Get Info,在Open with裡面選擇Xcode4並點擊Change All以設定檔案類型關聯。

二、熟悉介面

開啟Xcode,大概瀏覽下介面的變化,到處亂點下看是啥東西,把Xcode菜單瀏覽一遍。有空的話可以看看協助文檔裡面關於原始程式碼控制的部分。試著建一個HelloWorld項目,並操作下IB連結。

三、配置代碼編輯器的字型和顏色(Fonts & Colors)

我比較喜歡用黑色背景寫代碼,眼睛比較舒服。以前老的ColorTheme檔案用不了,ColorTheme的存放路徑變了,舊的在~/Library/Application Support/Xcode/Color Themes,Xcode4的在~/Library/Developer/Xcode/UserData/FontAndColorThemes下,而且檔案格式也變了,但是大部分項目都是一樣的。可以重新設定顏色字型,也可以對照著手動改設定檔。

Google了一下,aktowns已經寫了一個轉換指令碼:https://gist.github.com/793006

使用方法非常簡單:

1、下載dvtcolorconvert.rb,假如你放在案頭,把舊的Theme檔案也複製到案頭

  1. //dvtcolorconvert.rb  
  2.  
  3. #!/usr/bin/env ruby  
  4. # This script converts xccolorthemes to dtvcolorthemes for porting xcode 3.x themes to xcode 4.x   
  5. # created by ashley towns <ashleyis@me.com>   
  6. # Public domain.  
  7. # ./dvtcolorconvert <inputfile> 
  8. # spits out a .dtvcolortheme file  
  9.  
  10. require 'rubygems'  
  11. require 'plist'  
  12. raise "Error: need a source file #{__FILE__} [file.xccolortheme]" if ARGV.length == 0   
  13.  
  14. def alpha inc, alpha=1 
  15.   "#{inc} #{alpha}"  
  16. end  
  17. def convert infile  
  18.   hash = Plist::parse_xml infile  
  19.   out_hash = {}  
  20.   out_hash[:DVTSourceTextSyntaxFonts] = {}  
  21.   out_hash[:DVTSourceTextSyntaxColors] = {}  
  22.   hash.each do |name, node|  
  23.     node.each do |child_name, child|  
  24.       puts "[on] node:#{name} child:#{child_name}(#{child})"  
  25.       if name == "Colors"  
  26.         case child_name  
  27.           when /Background/   
  28.             out_hash[:DVTSourceTextBackground] = alpha child  
  29.             out_hash[:DVTConsoleTextBackgroundColor] = alpha child  
  30.             out_hash[:DVTSourceTextInvisiblesColor] = alpha child  
  31.             out_hash[:DVTSourceTextBlockDimBackgroundColor] = alpha child  
  32.           when /InsertionPoint/   
  33.             out_hash[:DVTSourceTextInsertionPointColor] = alpha child  
  34.             out_hash[:DVTConsoleTextInsertionPointColor] = alpha child  
  35.             out_hash[:DVTDebuggerInsutrctionPointerColor] = alpha child  
  36.             out_hash[:DVTConsoleDebuggerInputTextColor] = alpha child  
  37.             out_hash[:DVTConsoleDebuggerOutputTextColor] = alpha child  
  38.             out_hash[:DVTConsoleExectuableInputTextColor] = alpha child  
  39.             out_hash[:DVTConsoleExecutableOutputTextColor] = alpha child  
  40.           when /Selection/  
  41.             out_hash[:DVTSourceTextSelectionColor] = alpha child  
  42.             out_hash[:DVTConsoleTextSelectionColor] = alpha child  
  43.             out_hash[:DVTDebuggerPromptTextColor] = alpha child  
  44.           else  
  45.             out_hash[:DVTSourceTextSyntaxColors][child_name] = alpha child  
  46.         end  
  47.       elsif name == "Fonts"  
  48.         case child_name  
  49.           when /xcode.syntax.plain/  
  50.             child = "Inconsolata - 14pt" 
  51.             out_hash[:DVTConsoleDebuggerInputTextFont] = child  
  52.             out_hash[:DVTConsoleDebuggerOutputTextFont] = child  
  53.             out_hash[:DVTConsoleDebuggerPromptTextFont] = child  
  54.             out_hash[:DVTConsoleExecutableInputTextFont] = child  
  55.             out_hash[:DVTConsoleExecutableOutputTextFont] = child  
  56.             out_hash[:DVTSourceTextSyntaxFonts]['xcode.syntax.plain'] = child  
  57.           else  
  58.             out_hash[:DVTSourceTextSyntaxFonts][child_name] = "Inconsolata - 14pt" #child  
  59.         end  
  60.       else  
  61.         raise "I don't know what #{name} is."  
  62.       end  
  63.     end  
  64.   end  
  65.   puts "Saving #{infile.gsub(/xccolortheme/,'dvtcolortheme')}"  
  66.   fp = File.open(infile.gsub(/xccolortheme/,'dvtcolortheme'),'w')  
  67.   fp.write out_hash.to_plist  
  68.   fp.close  
  69. end  
  70.  
  71. convert ARGV[0]  
  72. #Dir['*.xccolortheme'].each do |file|  
  73. #  convert file  
  74. #end 

2、安裝"plist“ ruby gem: $sudo gem install plist

3、執行轉化: $ruby dvtcolorconvert.rb ElfDart.xccolortheme  就在案頭產生ElfDart.xccolortheme了,放到~/Library/Developer/Xcode/UserData/FontAndColorThemes下重啟Xcode4,在Preferences中的Fonts & Colors啟用主題。

我轉換後的主題檔案,

如果你喜歡的話可以在這裡下載到:http://code.google.com/p/elf-ios-resource/downloads/detail?name=ElfDark.dvtcolortheme

https://github.com/Sundae/Cocoa-Utilities

四、Preferences/Text Editing 圖示)

 

小結:Xcode學習文檔:Xcode4主題樣式的內容介紹完了,希望通過本文的學習能對你有所協助!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.