我想将字体大小和姓氏设置为titleLabel。 // Helvetica Neue UltraLight
[titleLabel setFont:[UIFont fontWithName:@"Helvetica Neue UltraLight" size:25.0f]];
这不起作用。
请告诉我可能出现的问题?
任何帮助将不胜感激?
答案 0 :(得分:36)
正确的fontName是@"HelveticaNeue-UltraLight"
。
使用类似这样的东西来获得格式良好的可用字体名称列表:
NSMutableString *str = [NSMutableString stringWithCapacity:1000];
for (NSString *familyName in [UIFont familyNames]) {
[str appendFormat:@"%@\n", familyName];
for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
[str appendFormat:@" %@\n", fontName];
}
[str appendString:@"\n"];
}
NSLog(@"%@", str);
这是iOS5.1的当前列表:
Thonburi
Thonburi-Bold
Thonburi
Snell Roundhand
SnellRoundhand-Bold
SnellRoundhand-Black
SnellRoundhand
Academy Engraved LET
AcademyEngravedLetPlain
Marker Felt
MarkerFelt-Wide
MarkerFelt-Thin
Geeza Pro
GeezaPro-Bold
GeezaPro
Arial Rounded MT Bold
ArialRoundedMTBold
Trebuchet MS
TrebuchetMS
TrebuchetMS-Bold
TrebuchetMS-Italic
Trebuchet-BoldItalic
Arial
Arial-BoldMT
ArialMT
Arial-ItalicMT
Arial-BoldItalicMT
Marion
Marion-Regular
Marion-Bold
Marion-Italic
Gurmukhi MN
GurmukhiMN
GurmukhiMN-Bold
Malayalam Sangam MN
MalayalamSangamMN-Bold
MalayalamSangamMN
Bradley Hand
BradleyHandITCTT-Bold
Kannada Sangam MN
KannadaSangamMN
KannadaSangamMN-Bold
Bodoni 72 Oldstyle
BodoniSvtyTwoOSITCTT-Book
BodoniSvtyTwoOSITCTT-Bold
BodoniSvtyTwoOSITCTT-BookIt
Cochin
Cochin
Cochin-BoldItalic
Cochin-Italic
Cochin-Bold
Sinhala Sangam MN
SinhalaSangamMN
SinhalaSangamMN-Bold
Hiragino Kaku Gothic ProN
HiraKakuProN-W6
HiraKakuProN-W3
Papyrus
Papyrus-Condensed
Papyrus
Verdana
Verdana
Verdana-Bold
Verdana-BoldItalic
Verdana-Italic
Zapf Dingbats
ZapfDingbatsITC
Courier
Courier-Bold
Courier
Courier-BoldOblique
Courier-Oblique
Hoefler Text
HoeflerText-Black
HoeflerText-Italic
HoeflerText-Regular
HoeflerText-BlackItalic
Euphemia UCAS
EuphemiaUCAS-Bold
EuphemiaUCAS
EuphemiaUCAS-Italic
Helvetica
Helvetica-LightOblique
Helvetica
Helvetica-Oblique
Helvetica-BoldOblique
Helvetica-Bold
Helvetica-Light
Hiragino Mincho ProN
HiraMinProN-W3
HiraMinProN-W6
Bodoni Ornaments
BodoniOrnamentsITCTT
Apple Color Emoji
AppleColorEmoji
Optima
Optima-ExtraBlack
Optima-Italic
Optima-Regular
Optima-BoldItalic
Optima-Bold
Gujarati Sangam MN
GujaratiSangamMN
GujaratiSangamMN-Bold
Devanagari Sangam MN
DevanagariSangamMN
DevanagariSangamMN-Bold
Times New Roman
TimesNewRomanPS-ItalicMT
TimesNewRomanPS-BoldMT
TimesNewRomanPSMT
TimesNewRomanPS-BoldItalicMT
Kailasa
Kailasa
Kailasa-Bold
Telugu Sangam MN
TeluguSangamMN-Bold
TeluguSangamMN
Heiti SC
STHeitiSC-Medium
STHeitiSC-Light
Apple SD Gothic Neo
AppleSDGothicNeo-Bold
AppleSDGothicNeo-Medium
Futura
Futura-Medium
Futura-CondensedExtraBold
Futura-CondensedMedium
Futura-MediumItalic
Bodoni 72
BodoniSvtyTwoITCTT-BookIta
BodoniSvtyTwoITCTT-Book
BodoniSvtyTwoITCTT-Bold
Baskerville
Baskerville-SemiBoldItalic
Baskerville-Bold
Baskerville-Italic
Baskerville-BoldItalic
Baskerville-SemiBold
Baskerville
Chalkboard SE
ChalkboardSE-Regular
ChalkboardSE-Bold
ChalkboardSE-Light
Heiti TC
STHeitiTC-Medium
STHeitiTC-Light
Copperplate
Copperplate
Copperplate-Light
Copperplate-Bold
Party LET
PartyLetPlain
American Typewriter
AmericanTypewriter-CondensedLight
AmericanTypewriter-Light
AmericanTypewriter-Bold
AmericanTypewriter
AmericanTypewriter-CondensedBold
AmericanTypewriter-Condensed
Bangla Sangam MN
BanglaSangamMN-Bold
BanglaSangamMN
Noteworthy
Noteworthy-Light
Noteworthy-Bold
Zapfino
Zapfino
Tamil Sangam MN
TamilSangamMN
TamilSangamMN-Bold
DB LCD Temp
DBLCDTempBlack
Arial Hebrew
ArialHebrew
ArialHebrew-Bold
Chalkduster
Chalkduster
Georgia
Georgia-Italic
Georgia-BoldItalic
Georgia-Bold
Georgia
Helvetica Neue
HelveticaNeue-Bold
HelveticaNeue-CondensedBlack
HelveticaNeue-Medium
HelveticaNeue
HelveticaNeue-Light
HelveticaNeue-CondensedBold
HelveticaNeue-LightItalic
HelveticaNeue-UltraLightItalic
HelveticaNeue-UltraLight
HelveticaNeue-BoldItalic
HelveticaNeue-Italic
Gill Sans
GillSans-LightItalic
GillSans-BoldItalic
GillSans-Italic
GillSans
GillSans-Bold
GillSans-Light
Palatino
Palatino-Roman
Palatino-Bold
Palatino-BoldItalic
Palatino-Italic
Courier New
CourierNewPSMT
CourierNewPS-BoldMT
CourierNewPS-BoldItalicMT
CourierNewPS-ItalicMT
Oriya Sangam MN
OriyaSangamMN-Bold
OriyaSangamMN
Didot
Didot-Italic
Didot
Didot-Bold
Bodoni 72 Smallcaps
BodoniSvtyTwoSCITCTT-Book
答案 1 :(得分:25)
你使用错误的字体名称,正确的是:
[titleLabel setFont:[UIFont fontWithName:@"HelveticaNeue-UltraLight" size:25.0f]];
您可以使用UIFont中的+ fontNamesForFamilyName:方法查看给定字体系列的所有可用字体名称列表,例如:
[UIFont fontNamesForFamilyName:@"Helvetica Neue"]
编辑另请注意,某些字体可能不会出现在所有版本的iOS上,因为Apple会逐渐添加(有时可能会删除)标准操作系统中的字体。
似乎“HelveticaNeue-UltraLight”字体出现在OS 5.0版本中。如果您想在较旧的操作系统版本中使用它,则需要将其嵌入到您的应用程序中 - 请查看示例this answer以获取有关如何执行此操作的详细信息
答案 2 :(得分:3)
请参阅List of Fonts available in iOS 并根据此使用字体名称......