I want to add font image to and UILabel. I added new TTF file to my resource folder which is fontallo. Added project info Fonts fontallo.ttf.
Now I want to set those images which are inside the fontallo.
Please find the below images
[lbl_FontImage setFont:[UIFont fontWithName:#"fontello" size:30]];
Unable to set those image to UILabel. Need suggestion to resolve it.
I'm assuming that you have verified the font is loaded and set onto the label. If not you need to log all of the fonts loaded in the system, check it's there and find the correct font name to pass to UIFont.
You need to set the label text to a string containing the character you want. You generally need to know the character that the font is using, kind of like the location in the font file. Or, you can copy the character (from FontBook) directly into your code (though you might see a placeholder symbol in the code).
I'd say it's generally best not to copy and paste, but that's probably personal preference. Unicode is better to use. To get that you need a tool which will tell you the Unicode value of the character. Once you have that you can create the string and directly reference the character.
Make sure you add your font names to your project's .plist file:
Related
I am trying to create a custom keyboard using the app keyboard extension. I am happy with the layout but the output is depended on the UITextField's font.
Is there a way to force a different font (use special characters?) while using the keyboard ?
Thank you
It depends.
Text field (or any other view that draws text) uses 2 informations on how to show some text. One is the sequence of characters called String and the other one is how the string should be represented. The second one is then split it things like fonts, colors, line height, line breaking and wrapping...
So the keyboard alone is not enough to for instance present a certain part of word using different fonts. You need at least a bit of access to the item that represents the text. So if you have no access to your text field then the answer is; No, you can not fore a different font when using different keyboard.
If you do have the access then the answer should lie in NSAttributedString. It is a string you can assign to most items under attributedText. This class wraps your raw string and can add many properties to parts of text you want to change. That includes using a different font.
Another approach would be using HTML tags. Again you will need to process this using for instance NSAttributedString or display it with another element like web view.
I would try it with using NSAttributedString. Hook up to delegate and implement textField(: shouldChangeCharactersIn: replacementString:. The implementation itself may still not be easy though.
I have custom Chivo font, added via cocoapod.
So, in xib I can find it using Title Plain, as you can see:
But if I need to use Attributed Title (for example to use 2 types: regular and bold in same string),
I can't find Chivo font:
So how to fix this? I sure can use it from code, but wonder if it can work in described way.
Thanks for help!
I need square bulleted(colored) text as follows
◼︎ Some large amount of text that
make it span to the next line.
to be shown in UITextView. But the problem is it doesn't git the padding on the next line.
◼︎ Some large amount of text that
make it span to the next line.
These bulleted text is of static content and hence no need to set it through code.
Also custom font is not working when I set attributed type. Custom font used is Raleway.
You need to set up a ruler with a "hanging indent." I have no idea how to do this manually with text attributes.
I would suggest instead setting up what you want in a .rtf file and then loading an attributed string from the RTF using either initWithURL:options:documentAttributes:error: (which is only available in iOS 9 or later) or initWithData:options:documentAttributes:error: (which is available in iOS >= 7.0.)
You specify an options dictionary of
Objective-C:
#{NSDocumentTypeDocumentAttribute:NSRTFTextDocumentType}
Swift:
[NSDocumentTypeDocumentAttribute:NSRTFTextDocumentType]
in the attribute inspector i have a placeholder (a.k.a a hint) for a textfield. The hint is called USERNAME. I'd like to localize this. I have already added the necessary strings into a localizable.strings file. My question is i would rather reference this string from the inspector itself. I wish i could do something like localstrings(#"username") right inside the placeholder field itself. I wish i could localize the placeholder string directly from interface builder is what i'm asking for. I've attached an image showing what i'd like to accomplish.
Localize your storyboard(Main.storyboard), Xcode makes strings file(Main.storyboard) for you, so edit it like...
"XXXXXXX.placeholder" = "NOMBRE";
I looked at a few examples here on OS and also followed this one but what I wanted to know is how I can set a custom font for only one specific label.
This line is supposed to change the font:
[UIFont fontWithName:#"Cloister Black" size:64.0]
But I don't want everything to be affected. Any ideas how I do this?
Setting the font on a label is as easy as modifying that label's "font" property (and I've linked Apple's documentation for you).
E.G.:
labelIWantToModify.font = [UIFont fontWithName:#"Cloister Black" size:64.0];
And I'm hoping you're referring to that one specific label, and not a piece or part of the string that appears within the label, which is a separate (attributed string) thing.