iOS中的可用字体

想单独指定某段文本字体类型,但是sdk文档中似乎没有iphone可用字体列表 ,找到一种方法,可以查看当前sdk可用字体类型

执行如下代码

NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
    NSArray *fontNames;
    NSInteger indFamily, indFont;
    for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
    {
        NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
        fontNames = [[NSArray alloc] initWithArray:
                     [UIFont fontNamesForFamilyName:
                      [familyNames objectAtIndex:indFamily]]];
        for (indFont=0; indFont<[fontNames count]; ++indFont)
        {
            NSLog(@"    Font name: %@", [fontNames objectAtIndex:indFont]);
        }
    }

即可打印当前sdk下全部字体,打印过如下

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


调用方法是这样的,可以通过下面方法调用:

UIFont *font=[UIFont fontWithName:<#(NSString *)#> size:<#(CGFloat)#>];


即一个改变Label上字体的格式的例子:

    UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(20, 100, self.view.frame.size.width-40, 50)];
    label.font=[UIFont fontWithName:@"GurmukhiMN-Bold"  size:18.0];
    label.textColor=[UIColor grayColor];
    label.text=@"hahahaha";
    [self.view addSubview:label];



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值