I'm kind of newbie in Objective-C and I need some help
My problem is that I have a subclass of UITextField
, and I want to set the placeholder font to be custom with this code
- (void)drawPlaceholderInRect:(CGRect)rect {
[[self placeholder] drawInRect:rect withAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"Georgia Belle" size:25],NSForegroundColorAttributeName:RGBA(174, 150, 108, 1)}]; }
and I have the next issue. When I select iPad in the simulator, and I compile the program, everything goes as it should, but when I select a retina device I get the next Exception:
[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0].
What I'm asking is: why it works on non-retina but throws exceptions on retina, any kind of retina device.
Your problem is with your Font.
HelveticaNeueInterface-Regular
is the System font. Like: [UIFont systemFontOfSize:25]
In the other hand I can't use RGBA(174, 150, 108, 1)
I've got an issue in my code.
You should be sure that you have the font named "Georgia Belle" is in your project well imported.
Drag and drop Georgia Belle.ttf to your project
Open Info.plist and add a new line:
Open your Target / Build Phases / Copy Bundle Resources
Xcode fails here and sometimes its not adding our new font:
Click +
Done
Problem solved.
You can download my solution from GitHub
One last thing. This is a nice website with all the standard ios fonts: http://iosfonts.com