FAQ Database Discussion Community

Font type and color based on device

I have a UI that looks good on all iOS 8 devices I've tried so far except the iPad 3 - the blur effect doesn't work so my white text is hard to read. Is there a way I can change the color of that font just for that one...

UIFont extension in SWIFT

I am attempting to write a UIFont extension for Swift written project. I get the error 'AnyObject is not convertible to String'. How do I tackle this. Here's what I've done func listAllFontsOnSystem(){ var familyNames = NSArray(array: UIFont.familyNames()) var fontNames = [] var indFamily, indFont : NSInteger for (indFamily =...

changing the value of size in fontWithName has no visible effect

I'm trying to use this code to set my text's font to Helvetica Neue Thin [UIFont fontWithName:@"Helvetica Neue Thin" size:14.0f]; The text has the given font but changing the size in the code has no effect on the text visible in the app. EDIT- Full block of code nameLabel =...

Extension function asking for return type instead of parameter

I am creating an extension of UIFont in Swift that will return a custom font. import UIKit extension UIFont { func museoSansRounded900(size: CGFloat) -> UIFont { return UIFont(name: "MuseoSansRounded900", size: size)! } } However, when I use the extension self.titleLabel?.font = UIFont.museoSansRounded900(15.0) Xcode returns an error in design time saying...

Cannot add custom font to Xcode

OK, so I've done a lot of reading, followed several tutorials, and I still cannot add a custom font to my iOS app. I've (1) added and copied the fonts to xcode. I've (2) added them to the correct target. I've (3) made sure they are included as resources in...

How to added font image to uilabel

I want to add font image to and UILabel. I added new TTF file to my resource folder which is fontallo. Added project info Fonts fontallo.ttf. Now I want to set those images which are inside the fontallo. Please find the below images [lbl_FontImage setFont:[UIFont fontWithName:@"fontello" size:30]]; Unable to set...

How to get monospaced numbers in UILabel on iOS 9

In this years WWDC there was a session about the new system font SanFrancisco in iOS 9 which uses proportional number rendering instead of monospaced numbers per default when linked against the iOS 9 SDK. There is a convenient initializer on NSFont called NSFont.monospacedDigitsSystemFontOfSize(mySize weight:) that can be used to...

UIFont doesn't set the correct font name when pointSize is 0

Why does UIFont incorrectly print out the font name when the size is set to zero? When I set the size to anything greater than zero, then the correct font name is output. Is there a particular reason behind this behavior or is this a true bug. UIFont* f1 =...

Why is boundingRectWithSize wrong when using UIFont preferredFontForTextStyle?

I have found that a call to boundingRectWithSize is extremely incorrect, missing an entire additional line, when called with NSFontAttributeName : [UIFont preferredFontForTextStyle:UIFontTextStyleBody]. However, using the font [UIFont fontWithName:@"Helvetica Neue" size:17.f], it is just fine. Here is test code showing the bug: - (void)viewDidLoad { [super viewDidLoad]; NSString *measureText =...

changing UITableViewCell text font

I was able to change the font of the tableViewCell text using this code cell.textLabel?.font = UIFont(name: "Snell Roundhand", size: 40) However i would also like to make this font bold, so far I've tried to do this by using this code cell.textLabel?.font = UIFont.boldSystemFontOfSize(40) Although this does change the...

Why am I unable to save my UIFontDescriptor into a variable?

I have the following code: UIFontDescriptor *fd = [UIFont fontWithDescriptor:[[UIFont systemFontOfSize:[UIFont systemFontSize]].fontDescriptor fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold|UIFontDescriptorTraitItalic]; But it gives me the error "Expected expression". What does that mean?...

Not able to set custom fonts in WatchKit

I am trying to set Roboto font and have added as target for watch kit extension, but it is still coming as nil. Can we set custom fonts in watch kit.