简体   繁体   中英

How i can change font to UITextView in swift?

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! :)

试试这个 :

textFieldDescrizione.font = UIFont(name: "NameOfTheFont", size: 20)

对于Swift 4,这对我有用

textView.font = UIFont(name: "Courier", size: 20)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM