我正在尝试在我的应用程序中嵌入自定义字体。
我已将Font文件包含在我的项目中
我将密钥添加到.plist
我将字体添加到目标
结果:
NSLog(@"Fonts: %@", [UIFont familyNames]);
Fonts: (
Thonburi,
"Snell Roundhand",
"Academy Engraved LET",
Avenir,
"Marker Felt",
"Geeza Pro",
"Arial Rounded MT Bold",
"Trebuchet MS",
Arial,
Marion,
"Gurmukhi MN",
"Malayalam Sangam MN",
"Bradley Hand",
"Kannada Sangam MN",
"Bodoni 72 Oldstyle",
Cochin,
"Sinhala Sangam MN",
"Hiragino Kaku Gothic ProN",
Papyrus,
Verdana,
"Zapf Dingbats",
"Avenir Next Condensed",
Courier,
"Hoefler Text",
Helvetica,
"Euphemia UCAS",
"Hiragino Mincho ProN",
"Bodoni Ornaments",
"Apple Color Emoji",
Optima,
"Gujarati Sangam MN",
"Devanagari Sangam MN",
"Times New Roman",
Kailasa,
"Telugu Sangam MN",
"Heiti SC",
"Apple SD Gothic Neo",
Futura,
"Bodoni 72",
Baskerville,
"Chalkboard SE",
"Heiti TC",
Copperplate,
"Party LET",
"American Typewriter",
Symbol,
"Avenir Next",
Noteworthy,
"Bangla Sangam MN",
Zapfino,
"Tamil Sangam MN",
Chalkduster,
"Arial Hebrew",
Georgia,
"Helvetica Neue",
"Gill Sans",
Palatino,
"Courier New",
"Oriya Sangam MN",
Didot,
"Bodoni 72 Smallcaps"
)
我的字体没有列在那里,这是我正在使用的代码:
[UIFont fontWithName:@"KozGoPr6N-Regular.ttf" size:self.LabelEmail.font.pointSize];
使用上面的代码,字体的大小并不总是会改变,只是有些时候。
IE,当我用0.20替换self.LabelEmail.font.pointSize大小保持完全相同时,标签从IB连接为IBOutlet,字体在IB中设置为14分
答案 0 :(得分:1)
[UIFont fontWithName:@"KozGoPr6N-Regular.ttf" size:self.LabelEmail.font.pointSize];
首先,我很确定“.ttf”不是(内部)字体名称的一部分。
代码应如下所示:
[UIFont fontWithName:@"KozGoPr6N-Regular" size:self.LabelEmail.font.pointSize];
其次,您是否自己将此字体从OpenType(.otf)转换为TrueType(.ttf)? (我在我的机器上快速搜索了这个字体,但它是安装在/ Library / Fonts /中的OpenType字体。