uifont

Using the fontWithSize API with San Francisco

和自甴很熟 提交于 2019-12-06 10:36:18
The new San Francisco fonts in iOS 9 are optimized for the size it will be used at, by adjusting tracking and dynamically switching between SF Display and SF Text. It was noted in the WWDC session #804 developers should not use San Francisco by attempting to initialize a UIFont using fontWithName , for example: UIFont *originalFont = [UIFont systemFontOfSize:11]; UIFont *newFont = [UIFont fontWithName:originalFont.fontName size:44]; This is because the system cannot optimize the font for the new size when using the fontWithName API. Instead it was recommended to get the UIFontDescriptor from

How to use alternate font weights (e.g. “short”) in a WKInterfaceLabel?

拥有回忆 提交于 2019-12-06 04:34:48
In Apple's Apple Watch Design Resources , there is a document called Alternate Font Weights and Italicizations . In it, it shows examples of what the default font looks like with different attributes such as Italic , Emphasized , and Short applied to it. Assume I want to use a font that looks exactly like the "Short" example. Is there any way to choose this font and style via the storyboard for a label? In code, how would I set a label to use this font and style? Senseful In an iOS project, I tried modifying the body font ( UIFontTextStyleBody ) to include UIFontDescriptorTraitTightLeading .

Can I preload custom fonts on iPhone to improve performance?

会有一股神秘感。 提交于 2019-12-06 03:59:56
问题 I've added the UIAppFonts entry on my info.plist to enable custom ttf fonts, it works fine. However when using the font there's also a delay in the UIView the first time it's called, is there a way to preload the fonts or some other technique to avoid this? Thanks 回答1: In your application delegate or some other place that is called when the application launches try creating a hidden UILabel that uses your custom font and remove it straight away. That way it will preload the font so that the

UIFont custom font not displaying on device

*爱你&永不变心* 提交于 2019-12-05 19:24:27
I have a problem with custom font. Namely it's Tw Cen MT.ttf It's the same problem as in here: Custom font not showing on device, but does on simulator Except the given solution doesn't work for me. I have done exactly what you should do: Added Font to Info.plist Added Font to Copy Bundle Resources section in Build Phases. Used font programmatically by name not filename. It still doesn't work. What's more interesting - when I list available fonts: NSLog(@"%@", [UIFont familyNames]); It shows me my font on simulator but does not show it on the device. I tested it both on the new iPad and iPhone

Swift 3 error: [_SwiftValue pointSize] unrecognized selector sent to instance

不羁的心 提交于 2019-12-05 08:46:10
问题 I just migrated our project to swift 3 and see lots of crashes because of one issue: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_SwiftValue pointSize]: unrecognized selector sent to instance The reason for that error is the call to: [NSAttributedString(NSExtendedStringDrawing) boundingRectWithSize:options:context:] What I noticed is that if I cast String to NSString and call boundingRectWithSize on it it will throw that error. It also seems to be

Is there a medium weight font between -systemFontOfSize: and -boldSystemFontOfSize:?

帅比萌擦擦* 提交于 2019-12-05 08:27:24
问题 -systemFontOfSize is too thin, and boldSystemFontOfSize too thick. I need something inbetween. When I create a UIFont like this: [UIFont boldSystemFontOfSize:14]; then the debugger prints this font info: font-family: ".Helvetica NeueUI"; font-weight: bold; font-style: normal; font-size: 14px Sometimes fonts have a medium font weight. How can I create a font of this type but with a medium weight? 回答1: Calling NSLog(@"%@", [UIFont fontNamesForFamilyName:@"Helvetica Neue"]); prints all available

Writing Hindi language on UILabel in Xcode

纵然是瞬间 提交于 2019-12-05 07:56:55
问题 I have written a code where I need to display hindi numbers on the UILabel. I used devanagari font to show that value but it doesn't work. It just changes the look but not the language. I was using: UIFont *font = [UIFont fontWithName:@"DevanagariSangamMN" size:16]; myLabel.font = font; But it's not working. Can anyone please help me with this? 回答1: You have got the font name wrong. The font name is DevanagariSangamMN not DevanagarSangamMN (note the missing 'i' in your name). Your code should

Adding multiple fonts to UIAppFonts overrides each other

☆樱花仙子☆ 提交于 2019-12-05 07:08:44
I'm trying to add some custom fonts to an iPhone app through UIAppFonts in Info.plist . I can reach both fontnames by code, i.e. MyFont-Bold and MyFont-Medium . My problem is that the last font in UIAppFonts array overrides the other one, making both MyFont-Bold and MyFont-Medium render out MyFont-Bold if this is the last entry in the plist array. By dragging MyFont-Bold as the first entry makes both font-names render MyFont-Medium. The property list excerpt: UIAppFonts item 0 MyFont-Medium item 1 MyFont-Bold I'm calling the font with: UIFont* applicationFontBold = [UIFont fontWithName:@

how to add new font to Xcode 3.2?

不问归期 提交于 2019-12-05 02:12:55
问题 please tell me how to add new font to iphone xcode3.2. 回答1: This functionality isn't built into UILabel/UIFont in iOS < 3.2. But there is a third-party solution you can use: FontLabel In iOS 3.2+, there's the UIAppFonts plist key! Just do this before using it: add your font file (such as myfont.ttf ) to your project, then edit the Info.plist like so: info.plist http://cl.ly/97da7a4f67b1b81a540f/content 回答2: The above methods worked for me in xcode 3.2! Thanks!: step 1: drag your font into

How to set font name of UILabel as HelveticaNeue Thin in iOS?

蓝咒 提交于 2019-12-04 22:51:34
I am creating UILabel, for the label i can set the font name as HelveticaNeue Regular, Light, UltraLight etc, But i unable to set the font name as HelveticaNeue Thin, it is not working as expected. I did like, label.font = [UIFont fontWithName:@"HelveticaNeue-Thin" size:16]; Also i have searched on Google didnt got any solution. How to fix this issue? Thanks. This font is bundled with iOS 7, so if you're targeting iOS 7 and above your label.font = [UIFont fontWithName:@"HelveticaNeue-Thin" size:16.0f]; will work. However if you are targeting iOS 6.1 and below you'll need to embed the font