UILabel and fonts
-
29-10-2019 - |
Question
How can I can use the font: HelveticaNeue Regular
in my labels? I can do it with IB, but programmatically that seems that it's not possible.
Is HelveticaNeue-Medium the regular one or HelveticaNeue?
Solution
You can find all fonts here:
For Helvetica you would do:
In Objective-C:
UIFont *helvFont = [UIFont fontWithName:@"HelveticaNeue" size:14.0];
In Swift:
let helvFont = UIFont(name: "HelveticaNeue", size: 14.0)
So the regular one would indeed by HelveticaNeue
OTHER TIPS
Here's a list of the fonts available on iOS:
If you want to use the system font, just use [UIFont systemFontOfSize:]
or [UIFont boldSystemFontOfSize:]
Swift 2.1:
var yourFont = UIFont(name: "", size: 30)
and to get a list of available fonts in your specific scenario:
print(UIFont.familyNames())
Try this it's work for me,
Objective-C
myLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:32.0f];
Swift
myLabel.font = UIFont(name: "HelveticaNeue-Light", size: 32.0)
On iOS Fonts you will find the full list of fonts and their names.
self.uilabel.text = "UNIVERSITY"
let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.black,NSAttributedString.Key.font: UIFont(name: "HelveticaNeue", size: 18.0)!]
navigationController?.navigationBar.titleTextAttributes = textAttributes
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow