Question or problem in the Swift programming language:
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?
How to solve the problem:
Solution 1:
You can find all fonts here:
list of iPhone fonts
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
Solution 2:
Here’s a list of the fonts available on iOS:
http://iosfonts.com/
If you want to use the system font, just use [UIFont systemFontOfSize:]
or [UIFont boldSystemFontOfSize:]
Solution 3:
Swift 2.1:
var yourFont = UIFont(name: "", size: 30)
and to get a list of available fonts in your specific scenario:
print(UIFont.familyNames())
Solution 4:
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.
Solution 5:
self.uilabel.text = "UNIVERSITY" let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.black,NSAttributedString.Key.font: UIFont(name: "HelveticaNeue", size: 18.0)!] navigationController?.navigationBar.titleTextAttributes = textAttributes