Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How i can change font to UITextView in swift?

Tags:

ios

swift

fonts

Hy guys I want that my textView have this font: "Apple SD Gothic Light"... I used this code here belong:

if (titolo.text == NSLocalizedString("SEVENTH_ANNOTATION_TITLE", comment: "")){
    // aggiungo le immagini all'array
    pageImages = [UIImage(named: "TeatroMassimoBellini1.png")!,
                  UIImage(named: "TeatroMassimoBellini2.png")!,
                  UIImage(named: "TeatroMassimoBellini3.png")!]

    textFieldDescrizione.text = NSLocalizedString("SEVENTH_ANNOTATION_DESCRIPTION", comment: "")
    textFieldDescrizione.font = UIFont.preferredFontForTextStyle("AppleSDGothicNeo-Light")
    textFieldDescrizione.textAlignment = NSTextAlignment.Justified
}

but it doesn't work.... Can you help me? Sorry for my english! :)

like image 445
Giuseppe Puglisi Avatar asked Mar 18 '15 18:03

Giuseppe Puglisi


People also ask

How do I change the textfield font in Swift?

yes you can do it. [tFild_1 setFont:[UIFont fontWithName:@"Helvetica Neue" size:17]]; instead of "Helvetica Neue" use your font name.

How do I change font size in Swift?

Change Font And Size Of UILabel In Storyboard XIB file, open it in the interface builder. Select the label and then open up the Attribute Inspector (CMD + Option + 5). Select the button on the font box and then you can change your text size or font.

How do I change font size in Textview in Swift?

Swift 2 & 3: import UIKit extension UITextView { func increaseFontSize () { self. font = UIFont(name: (self. font?. fontName)!, size: (self.


2 Answers

Try this :

textFieldDescrizione.font = UIFont(name: "NameOfTheFont", size: 20)
like image 162
Victor Sigler Avatar answered Oct 19 '22 06:10

Victor Sigler


For Swift 4 , this worked for me

textView.font = UIFont(name: "Courier", size: 20)
like image 45
Guri S Avatar answered Oct 19 '22 05:10

Guri S