Hiho,
I am trying to set a font for my label, but it just doesn't appear in my iOS-Simulator when I run the app.
_textLabel1 = [[UILabel alloc] initWithFrame:CGRectMake((CGFloat) (self.view.center.x - (self.view.bounds.size.width / textWidth / 2)),
(CGFloat) (self.view.center.y * textPositionY), (CGFloat) (self.view.bounds.size.width / textWidth), (CGFloat) textHeight)];
_textLabel1.numberOfLines = 0;
_textLabel1.textAlignment = NSTextAlignmentCenter;
_textLabel1.textColor = clr;
_textLabel1.text = @"Favoriten";
[_textLabel1 setFont:[UIFont fontWithName:@"assets/fonts/Kingthings_Trypewriter_2.ttf" size:36]];
[_favouriteViewer addSubview:_textLabel1];
_textLabel1.font=[_textLabel1.font fontWithSize:25];
I also added the custom font in my plist:
<key>UIAppFonts</key>
<array>
<string>Kingthings_Trypewriter_2.ttf</string>
</array>
I saved my custom font in the named asset folder wich I called in:
[_textLabel1 setFont:[UIFont fontWithName:@"assets/fonts/Kingthings_Trypewriter_2.ttf" size:36]];
I does not show the font in the simulator.
Thanks for the help!
Edit: I am using AppCode, not Xcode.
Edit2:
Thanks to Ganesh Somani, I used his code to try to find out if my font is correctly added to the project via the Copy Bundle ressources but unfortunately it is still not showing up in the log.
for(NSString *fontfamilyname in [UIFont familyNames])
{
NSLog(@"Family:'%@'",fontfamilyname);
for(NSString *fontName in [UIFont fontNamesForFamilyName:fontfamilyname])
{
NSLog(@"\tfont:'%@'",fontName);
}
NSLog(@"---");
}
Solution: For some reason I had two .plist files in my project. I put in the following code and now it works:
<key>UIAppFonts</key>
<array>
<string>"fontName.ttf"</string>
</array>
Thanks to all contributers for the help!