1. 程式人生 > >iOS開發 之字型型別的設定與選擇

iOS開發 之字型型別的設定與選擇

宣告:
    文章轉自新浪博主:Apple_ 小熊貓    原文地址:http://blog.sina.com.cn/s/blog_b22973cf0101auqv.html。轉載時請附帶宣告。

ios中的字型:

    字型是圖形使用者介面顯示文字的基礎。Cocoa在UIKit框架中為開發者提供了高層次的API以及方便的列舉、載入和使用字型。Cocoa Touch 使用UIFont 類來封裝字型。每個ios裝置都內建了系統字型。字型被組織成字型族科(Families),每個族科又包含字樣(Faces)。例如,Helvetica 是一個字型族科,Helvetica Bold是Helvetica族科中的一個字樣。要載入字型,你必須知道字型的字樣(字型的名字),要知道字樣,你必須知道它的族科。怎麼獲取系統字型的族科呢,我們可以迴圈輸出系統字型族科,使用UIFont類的familyNames類方法,通過這個類方法得到字型族科名字然後用UIFont類的fontNamesForFamilyName:類方法,傳遞family name作為引數,並返回一個字型名稱的陣列(array):

  1. - (void)enumerateFonts{  
  2.       for(NSString *familyName in [UIFont familyNames]){  
  3.       NSLog(@"Font FamilyName = %@",familyName); //*輸出字型族科名字  
  4.         for(NSString *fontName in [UIFont fontNameForFamilyName:familyName]){  
  5.             NSLog(@"\t%@",fontName);         //*輸出字型族科下字樣名字  
  6.         }  
  7.     }  
  8. }  

在ios模擬器上執行程式碼,得到如下結果:

...
Font Family = Geeza Pro
GeezaPro
GeezaPro-Bold
Font Family = Helvetica Neue
HelveticaNeue-Italic
HelveticaNeue-Bold
HelveticaNeue-BoldItalic
HelveticaNeue

...

字型族科後面加-Bold就是加粗 加-Oblique就是傾斜等

iPhone 5.0 iPad 5.0
Font Families: 58 Font Families: 58
Academy Engraved LET
AcademyEngravedLetPlain AcademyEngravedLetPlain
American Typewriter
AmericanTypewriter-CondensedLight AmericanTypewriter-CondensedLight
AmericanTypewriter-Light AmericanTypewriter-Light
AmericanTypewriter AmericanTypewriter
AmericanTypewriter-Condensed AmericanTypewriter-Condensed
AmericanTypewriter-Bold AmericanTypewriter-Bold
AmericanTypewriter-CondensedBold AmericanTypewriter-CondensedBold
Apple Color Emoji
AppleColorEmoji AppleColorEmoji
Apple SD Gothic Neo
AppleSDGothicNeo-Medium AppleSDGothicNeo-Medium
AppleSDGothicNeo-Bold AppleSDGothicNeo-Bold
Arial
ArialMT ArialMT
Arial-ItalicMT Arial-ItalicMT
Arial-BoldMT Arial-BoldMT
Arial-BoldItalicMT Arial-BoldItalicMT
Arial Hebrew
ArialHebrew ArialHebrew
ArialHebrew-Bold ArialHebrew-Bold
Arial Rounded MT Bold
ArialRoundedMTBold ArialRoundedMTBold
Bangla Sangam MN
BanglaSangamMN-Bold BanglaSangamMN-Bold
BanglaSangamMN BanglaSangamMN
Baskerville
Baskerville Baskerville
Baskerville-Italic Baskerville-Italic
Baskerville-SemiBold Baskerville-SemiBold
Baskerville-SemiBoldItalic Baskerville-SemiBoldItalic
Baskerville-Bold Baskerville-Bold
Baskerville-BoldItalic Baskerville-BoldItalic
Bodoni 72
BodoniSvtyTwoITCTT-Book BodoniSvtyTwoITCTT-Book
BodoniSvtyTwoITCTT-BookIta BodoniSvtyTwoITCTT-BookIta
BodoniSvtyTwoITCTT-Bold BodoniSvtyTwoITCTT-Bold
Bodoni 72 Oldstyle
BodoniSvtyTwoOSITCTT-Book BodoniSvtyTwoOSITCTT-Book
BodoniSvtyTwoOSITCTT-BookIt BodoniSvtyTwoOSITCTT-BookIt
BodoniSvtyTwoOSITCTT-Bold BodoniSvtyTwoOSITCTT-Bold
Bodoni 72 Smallcaps
BodoniSvtyTwoSCITCTT-Book BodoniSvtyTwoSCITCTT-Book
Bodoni Ornaments
BodoniOrnamentsITCTT BodoniOrnamentsITCTT
Bradley Hand
BradleyHandITCTT-Bold BradleyHandITCTT-Bold
Chalkboard SE
ChalkboardSE-Light ChalkboardSE-Light
ChalkboardSE-Regular ChalkboardSE-Regular
ChalkboardSE-Bold ChalkboardSE-Bold
Chalkduster
Chalkduster Chalkduster
Cochin
Cochin Cochin
Cochin-Italic Cochin-Italic
Cochin-Bold Cochin-Bold
Cochin-BoldItalic Cochin-BoldItalic
Copperplate
Copperplate-Light Copperplate-Light
Copperplate Copperplate
Copperplate-Bold Copperplate-Bold
Courier
Courier Courier
Courier-Oblique Courier-Oblique
Courier-Bold Courier-Bold
Courier-BoldOblique Courier-BoldOblique
Courier New
CourierNewPSMT CourierNewPSMT
CourierNewPS-BoldMT CourierNewPS-BoldMT
CourierNewPS-BoldItalicMT CourierNewPS-BoldItalicMT
CourierNewPS-ItalicMT CourierNewPS-ItalicMT
DB LCD Temp
DBLCDTempBlack DBLCDTempBlack
Devanagari Sangam MN
DevanagariSangamMN DevanagariSangamMN
DevanagariSangamMN-Bold DevanagariSangamMN-Bold
Didot
Didot Didot
Didot-Italic Didot-Italic
Didot-Bold Didot-Bold
Euphemia UCAS
EuphemiaUCAS EuphemiaUCAS
EuphemiaUCAS-Italic EuphemiaUCAS-Italic
EuphemiaUCAS-Bold EuphemiaUCAS-Bold
Futura
Futura-Medium Futura-Medium
Futura-MediumItalic Futura-MediumItalic
Futura-CondensedMedium Futura-CondensedMedium
Futura-CondensedExtraBold Futura-CondensedExtraBold
Geeza Pro
GeezaPro GeezaPro
GeezaPro-Bold GeezaPro-Bold
Georgia
Georgia Georgia
Georgia-Italic Georgia-Italic
Georgia-Bold Georgia-Bold
Georgia-BoldItalic Georgia-BoldItalic
Gill Sans
GillSans-Light GillSans-Light
GillSans-LightItalic GillSans-LightItalic
GillSans GillSans
GillSans-Italic GillSans-Italic
GillSans-Bold GillSans-Bold
GillSans-BoldItalic GillSans-BoldItalic
Gujarati Sangam MN
GujaratiSangamMN GujaratiSangamMN
GujaratiSangamMN-Bold GujaratiSangamMN-Bold
Gurmukhi MN
GurmukhiMN GurmukhiMN
GurmukhiMN-Bold GurmukhiMN-Bold
Heiti SC
STHeitiSC-Light STHeitiSC-Light
STHeitiSC-Medium STHeitiSC-Medium
Heiti TC
STHeitiTC-Light STHeitiTC-Light
STHeitiTC-Medium STHeitiTC-Medium
Helvetica
Helvetica-Light Helvetica-Light
Helvetica-LightOblique Helvetica-LightOblique
Helvetica Helvetica
Helvetica-Oblique Helvetica-Oblique
Helvetica-Bold Helvetica-Bold
Helvetica-BoldOblique Helvetica-BoldOblique
Helvetica Neue
HelveticaNeue-UltraLight HelveticaNeue-UltraLight
HelveticaNeue-UltraLightItalic HelveticaNeue-UltraLightItalic
HelveticaNeue-Light HelveticaNeue-Light
HelveticaNeue-LightItalic HelveticaNeue-LightItalic
HelveticaNeue HelveticaNeue
HelveticaNeue-Italic HelveticaNeue-Italic
HelveticaNeue-Medium HelveticaNeue-Medium
HelveticaNeue-Bold HelveticaNeue-Bold
HelveticaNeue-BoldItalic HelveticaNeue-BoldItalic
HelveticaNeue-CondensedBold HelveticaNeue-CondensedBold
HelveticaNeue-CondensedBlack HelveticaNeue-CondensedBlack
Hiragino Kaku Gothic ProN
HiraKakuProN-W3 HiraKakuProN-W3
HiraKakuProN-W6 HiraKakuProN-W6
Hiragino Mincho ProN
HiraMinProN-W3 HiraMinProN-W3
HiraMinProN-W6 HiraMinProN-W6
Hoefler Text
HoeflerText-Regular HoeflerText-Regular
HoeflerText-Italic HoeflerText-Italic
HoeflerText-Black HoeflerText-Black
HoeflerText-BlackItalic HoeflerText-BlackItalic
Kailasa
Kailasa Kailasa
Kailasa-Bold Kailasa-Bold
Kannada Sangam MN
KannadaSangamMN KannadaSangamMN
KannadaSangamMN-Bold KannadaSangamMN-Bold
Malayalam Sangam MN
MalayalamSangamMN MalayalamSangamMN
MalayalamSangamMN-Bold MalayalamSangamMN-Bold
Marion
Marion-Regular Marion-Regular
Marion-Italic Marion-Italic
Marion-Bold Marion-Bold
Marker Felt
MarkerFelt-Thin MarkerFelt-Thin
MarkerFelt-Wide MarkerFelt-Wide
Noteworthy
Noteworthy-Light Noteworthy-Light
Noteworthy-Bold Noteworthy-Bold
Optima
Optima-Italic Optima-Italic
Optima-Regular Optima-Regular
Optima-Bold Optima-Bold
Optima-BoldItalic Optima-BoldItalic
Optima-ExtraBlack Optima-ExtraBlack
Oriya Sangam MN
OriyaSangamMN OriyaSangamMN
OriyaSangamMN-Bold OriyaSangamMN-Bold
Palatino
Palatino-Roman Palatino-Roman
Palatino-Italic Palatino-Italic
Palatino-Bold Palatino-Bold
Palatino-BoldItalic Palatino-BoldItalic
Papyrus
Papyrus Papyrus
Papyrus-Condensed Papyrus-Condensed
Party LET
PartyLetPlain PartyLetPlain
Sinhala Sangam MN
SinhalaSangamMN SinhalaSangamMN
SinhalaSangamMN-Bold SinhalaSangamMN-Bold
Snell Roundhand
SnellRoundhand SnellRoundhand
SnellRoundhand-Bold SnellRoundhand-Bold
SnellRoundhand-Black SnellRoundhand-Black
Tamil Sangam MN
TamilSangamMN TamilSangamMN
TamilSangamMN-Bold TamilSangamMN-Bold
Telugu Sangam MN
TeluguSangamMN TeluguSangamMN
TeluguSangamMN-Bold TeluguSangamMN-Bold
Thonburi
Thonburi Thonburi
Thonburi-Bold Thonburi-Bold
Times New Roman
TimesNewRomanPSMT TimesNewRomanPSMT
TimesNewRomanPS-ItalicMT TimesNewRomanPS-ItalicMT
TimesNewRomanPS-BoldMT TimesNewRomanPS-BoldMT
TimesNewRomanPS-BoldItalicMT TimesNewRomanPS-BoldItalicMT
Trebuchet MS
TrebuchetMS TrebuchetMS
TrebuchetMS-Italic TrebuchetMS-Italic
TrebuchetMS-Bold TrebuchetMS-Bold
Trebuchet-BoldItalic Trebuchet-BoldItalic
Verdana
Verdana Verdana
Verdana-Italic Verdana-Italic
Verdana-Bold Verdana-Bold
Verdana-BoldItalic Verdana-BoldItalic
Zapf Dingbats
ZapfDingbatsITC ZapfDingbatsITC