简体   繁体   English

我如何在swift中将字体更改为UITextView?

[英]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: Hy们我希望我的textView有这样的字体: "Apple SD Gothic Light" ......我在这里使用的代码属于:

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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