uifont

Giving Framesetter the correct line spacing adjustment

微笑、不失礼 提交于 2019-11-30 15:53:33
Several posts have noted difficulties with getting an exact height out of CTFramesetterSuggestFrameSizeWithConstraints, and here, (framesetter post) , @Chris DeSalvo gives what looks like the definitive fix: add a paragraph style setting with the correct line spacing adjustment. DeSalvo gets his “leading” by removing UIFont’s ascender and descender from its lineHeight. I wondered how that would compare to CTFontGetLeading . I worked with fonts created like this: CTFontRef fontr = CTFontCreateWithName((CFStringRef)@"Helvetica Neue", 16.0f, NULL); UIFont *font = [UIFont fontWithName:@"Helvetica

Changing tab bar font in Swift

ε祈祈猫儿з 提交于 2019-11-30 14:33:13
问题 I have been trying to change the font for the tab bar items however I haven't been able to find any Swift examples. I know that this is how you change it in Objective-C: [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"AmericanTypewriter" size:20.0f], UITextAttributeFont, nil] forState:UIControlStateNormal]; But how can I translate this into Swift? 回答1: The UITextAttributeFont was deprecated in iOS 7. You should use the NS

Resize UILabel based on content

自闭症网瘾萝莉.ら 提交于 2019-11-30 09:35:48
I have a UILabel, his text size has the property title.adjustsFontSizeToFitWidth = YES; that prevents me from using standard methods to resize the UILabel. I read on another post here that I'm supposed to use the function sizeWithFont:minFontSize:actualFontSize:forWidth:lineBreakMode from this answer: How to figure out the font size of a UILabel when -adjustsFontSizeToFitWidth is set to YES? Now, i can't figure out how to make it work.. this is the actual code UIFont *font = [UIFont fontWithName:@"Marker Felt" size:200]; UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0,

How to check if a character is supported by a font

限于喜欢 提交于 2019-11-30 09:05:11
问题 I'm working on an app with a text field. The text wrote in this field will be printed and I have an issue with some characters like emoji, chinese characters, etc... because the font do not provide these characters. It's why I want to get all the character provided by a font (The font is downloaded so I can deal directly with the file or with an UIFont object). I heard about CTFontGetGlyphsForCharacters but I'm not sure that this function do what I want and I can't get it work. Here is my

How do you stylize a font in Swift?

蓝咒 提交于 2019-11-30 06:02:24
I'm trying out developing for Swift, it's going pretty well. One of the issues I'm having is finding out how to stylize fonts programmatically in the language. For example in this label I wrote the code below for, how can I make it Helvetica Neue Ultralight for example? label.font = UIFont (name: "Helvetica Neue", size: 30) KRUKUSA I am assuming this is a custom font. For any custom font this is what you do. First download and add your font files to your project in Xcode (The files should appear as well in “Target -> Build Phases -> Copy Bundle Resources”). In your Info.plist file add the key

Name of non-system font in iPhone

人走茶凉 提交于 2019-11-30 05:28:56
问题 I want to add a non-system font to my iPhone/iPad app. I have added the font file to the project and also added the font to the UIAppFonts property of the info.plist. To load the font I'm using fontWithName of UIFont . But the name of the font does not seem to be the file name, with or without extension, nor the name that appears in Font Book. UIFont* font = [UIFont fontWithName:@"What goes here?" size:10]; Where do I find out the name of the font? 回答1: UIFont 's +familyNames and then

Dynamic custom fonts loader in iOS

老子叫甜甜 提交于 2019-11-30 04:07:29
i already know how to load a custom font to my project in iPhone App from here I want to ask if there is a way to do this from code? My problem is that I have a resource folder in my app, i have a font file name, lets call it " myfont.ttf ". I want to grab a ttf file and put it to plist file from code , and what's more i want to know the display name for fontWithName:size: method. There is a way to achieve this? bontoJR Yes you can. But you've to work a lot with CoreText and/or CoreGraphics. There's a nice class from Zynga that could help you in doing this: https://github.com/zynga/FontLabel

Can't use custom font in iOS app

[亡魂溺海] 提交于 2019-11-29 23:59:40
问题 I'm trying to use custom font for my iOS app. Here is what I do I added my custom font (m.tff) to Xcode Supporting files directory. Also I create entry called Fonts provided by application with value name of the font (m.tff) in myApp.plist In my view I have a label UILabel *label = [[UILabel alloc]initWithFrame:CGRect(10, 20, 230, 30)]; label.font = [UIFont fontWithName:@"My custom font" size:15]; etc... The problem is that when I launch the app the text in label is with default font instead

What exactly is UIFont's point size?

a 夏天 提交于 2019-11-29 20:35:10
I am struggling to understand exactly what the point size in UIFont means. It's not pixels and it doesn't appear to be the standard definition of point which is that they relate to 1/72th inch. I worked out the pixel size using -[NSString sizeWithFont:] of fonts at various sizes and got the following: | Point Size | Pixel Size | | ---------- | ---------- | | 10.0 | 13.0 | | 20.0 | 24.0 | | 30.0 | 36.0 | | 40.0 | 47.0 | | 50.0 | 59.0 | | 72.0 | 84.0 | | 99.0 | 115.0 | | 100.0 | 116.0 | (I did [@"A" sizeWithFont:[UIFont systemFontOfSize:theSize]] ) And looking at the 72.0 point size, that is not

How can I calculate correct widths for UISegmentedControl segments?

二次信任 提交于 2019-11-29 18:51:19
问题 I'm trying to use a UISegmentedControl but having trouble calculating the width of the segments. The control makes the segments all the same width which doesn't work for some titles, like this one: http://morrisphotoart.com/tmp/Screenshot2011-07-13_21.17.33.png I can write code to calculate the segment width if I knew which font and call the setWidth:forSegmentAtIndex: method but how can I get the font? Or is there another way? The left and middle segment's titles are not fixed so I can't