swift - attributed text not working with custom font in xcode 7 -
i using xcode 7. when using attributed text custom font displays in storyboard not working on device. tried following code:
var mymutablestring = nsmutableattributedstring() let paragraphstyle = nsmutableparagraphstyle() paragraphstyle.linespacing = 8 paragraphstyle.alignment = nstextalignment.center mymutablestring = nsmutableattributedstring(string: "\"taking out shorts , t-shirt night before has helped create great morning routine walk\"", attributes: [nsfontattributename:uifont(name: "gotham medium", size: 20.0)!]) mymutablestring.addattribute(nsparagraphstyleattributename, value:paragraphstyle, range:nsmakerange(0, mymutablestring.length)) quoteslabel.attributedtext = mymutablestring
make sure app contains font file gotham medium. check out great article common mistakes adding custom fonts in ios apps.
- include fonts in xcode project
- make sure they’re included in target
- double check fonts included resources in bundle
- include ios custom fonts in application plist
- find name of font
- use uifont , specify name of font
Comments
Post a Comment