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

时间:2015-03-18 18:10:38

标签: ios swift fonts

我希望我的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
}

但它不起作用....你能帮助我吗? 对不起我的英语不好! :)

2 个答案:

答案 0 :(得分:30)

试试这个:

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

答案 1 :(得分:2)

对于Swift 4来说,这对我有用

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