簡體   English   中英

我如何在swift中將字體更改為UITextView?

[英]How i can change font to UITextView in swift?

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
}

但它不起作用....你能幫助我嗎? 對不起我的英語不好! :)

試試這個 :

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