uifont

UITextView font to always be fixed size

一曲冷凌霜 提交于 2019-11-29 17:32:16
I have a UICollectionView with cells sized to the same aspect ratio as a4 page. And with different screen sizes I would like for that text to be sized at fixed 12pt (that would be calculated to that UICollectionview cell), which would look bigger on the iPad and smaller on iPhone. So having a fixed font size isn't an option... Coding var fontSize : CGFloat = 12.0 // DEFAULT SIZE In your ViewDidLoad if UIDevice().userInterfaceIdiom == .phone { switch self.view.frame.size.height { case 480: fontSize = 12.0 case 568: fontSize = 14.0 case 667: fontSize = 16.0 case 736: fontSize = 17.0 case 812:

Resize UILabel based on content

≯℡__Kan透↙ 提交于 2019-11-29 14:30:44
问题 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

How to check if a character is supported by a font

北慕城南 提交于 2019-11-29 11:39:23
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 code : CTFontRef fontRef = CTFontCreateWithName((CFStringRef)font.fontName, font.pointSize, NULL);

Is it possible to use iOS 7's modified Helvetica in apps?

痴心易碎 提交于 2019-11-29 09:24:45
问题 For iOS 7, Apple made a special modified version of Helvetica Thin/Light that has rounded periods and colons: Compare this to using Helvetica-Neue Thin or Helvetica-Neue Light in Xcode: Is it possible to develop apps with the special modified version with the rounded colons and periods? EDIT : Turns out these round colons and periods are not custom designed by Apple, they are "character alternates" and you can see them in your favorite font glyph viewer. 回答1: Here's how to do it. Even reading

How do you stylize a font in Swift?

自古美人都是妖i 提交于 2019-11-29 04:25:52
问题 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) 回答1: 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

UIFont fontWithName returns nil

对着背影说爱祢 提交于 2019-11-29 02:54:55
In my info.plist, I added a key "Fonts provided by application" and added EdwardianScriptITCStd.otf But, when I try to get that font, it returns nil: NSLog(@"%@", [UIFont fontWithName:@"EdwardianScriptITCStd" size:16.0f]); I printed the font families using [UIFont familyNames] and it's not there either: ( Thonburi, "Snell Roundhand", "Academy Engraved LET", "Marker Felt", "Geeza Pro", "Arial Rounded MT Bold", "Trebuchet MS", Arial, Marion, "Gurmukhi MN", "Malayalam Sangam MN", "Bradley Hand", "Kannada Sangam MN", "Bodoni 72 Oldstyle", Cochin, "Sinhala Sangam MN", "Hiragino Kaku Gothic ProN",

Dynamic custom fonts loader in iOS

半世苍凉 提交于 2019-11-29 01:59:00
问题 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? 回答1: Yes you can. But you've to work a lot with CoreText and/or CoreGraphics.

iPhone SDK 3.2 and UIAppFonts

倾然丶 夕夏残阳落幕 提交于 2019-11-28 23:56:02
I've added my custom font to UIAppFonts and it's loaded just fine: (shows up in [UIFont familyNames] ). When I manually set the font in viewDidLoad { [myLabel setFont: [UIFont fontWithName:@"CustomFont" size: 65.0]]; } everything works and the font is rendered. However doing the same thing in IB doesn't (some other default font is used instead). Having to create IBOutlets for each label and fixing up the fonts manually in viewDidLoad is pretty painful. Anyone else had problems getting the custom font support to work with 3.2 SDK and IB? Opened a bug report with Apple and turns out it really is

Detect whether a font is bold/italic on iOS?

只愿长相守 提交于 2019-11-28 23:14:41
Given a UIFont or a CTFont, how can I tell whether the font is bold/italic? Looking at the font's name won't always work. Consider the font "Courier Oblique" (which is italic) or "HoeflerText-Black" (which is bold), Neither of those contain "bold" or "italic" in their names. Given a font as a CTFontRef , the proper way to determine whether it's bold or italic is to use the CTFontGetSymbolicTraits function: CTFontRef font = CTFontCreateWithName((CFStringRef)@"Courier Oblique", 10, NULL); CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(font); BOOL isItalic = ((traits & kCTFontItalicTrait)

Setting UILabel - Font through code - generates error - iPhone

十年热恋 提交于 2019-11-28 20:50:33
See following code carefully. Because it works perfectly. Try to add in your application. it will work - (void)viewDidLoad { [super viewDidLoad]; // title label - tip UILabel *tmp=[[UILabel alloc] initWithFrame:CGRectMake(50, 50, 200, 200)]; tmp.textColor=[UIColor colorWithRed:(14.0/255.0) green:(105.0/255) blue:(128.0/255) alpha:1.0]; [tmp setFont:[UIFont fontWithName:@"Arial" size:18]]; tmp.text=@"sagar"; tmp.backgroundColor=[UIColor clearColor]; [self.view addSubview:tmp]; [tmp release]; } Now, see following code carefully. Because it doesn't work. See there is nothing difference between