ios - UIFont not being set in UILabel- Swift -
i have uilabel , want font of text sf mono. so, use these lines of code:
let tagboxlabel = uilabel(frame: cgrect(x: 20, y: 0, width: 0, height: 0)) tagboxlabel.font = uifont(name: "sf mono regular", size: 10.0)
but text not set. have tried "sfmono-regular", "sfmono-regular.otf", etc. nothing.
i have correctly imported .otf project well, can access on storyboard.
does have clue of i'm doing wrong? immensely appreciated. in advance!
most not using correct font name. try this:
let fontfamilynames = uifont.familynames familyname in fontfamilynames { print("------------------------------") print("font family name = [\(familyname)]") let names = uifont.fontnames(forfamilyname: familyname) print("font names = [\(names)]") }
can try getting font name there , implement , run again? got code http://giordanoscalzo.tumblr.com/post/95900320382/print-all-ios-fonts-in-swift
second:
uifont.familynames.foreach({ familyname in let fontnames = uifont.fontnames(forfamilyname: familyname) print(familyname, fontnames) })
Comments
Post a Comment