I have following code in my Application.
tmp=[[UILabel alloc] initWithFrame:label1Frame];
tmp.tag=1;
tmp.textColor=[UIColor blackColor];
[tmp setFont:[UIFont
Swift update
If you've already added the font to the app (as explained here) you can use Swift's extension feature with, as example, a UILabel and the Roboto font:
extension UILabel {
func setFont(style: String, size: Int){
self.font = UIFont(name: style, size: CGFloat(size))
}
struct FontStyle {
public static let italic: String = "Roboto-LightItalic"
public static let normal: String = "Roboto-Light"
public static let thin: String = "Roboto-Thin"
}
}
Roboto-LightItalic and Roboto-Light are the TTF's font file names. Then, you can simply call
someUILabel.setFont(style: UILabel.FontStyle.normal, size: 20)