uifont

How to get monospaced numbers in UILabel on iOS 9

℡╲_俬逩灬. 提交于 2019-11-28 17:52:32
At WWDC 2015, there was a session about the new “San Francisco” system font in iOS 9. It uses proportional number rendering instead of monospaced numbers by 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 explicitly enable monospaced number display. However I couldn't find the UIKit equivalent for this on UIFont . Rudolf Adamkovič Handy UIFont extension: extension UIFont { var monospacedDigitFont: UIFont { let newFontDescriptor = fontDescriptor.monospacedDigitFontDescriptor

What exactly is UIFont's point size?

一世执手 提交于 2019-11-28 16:37:55
问题 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

How to change font of UIButton with Swift

筅森魡賤 提交于 2019-11-28 15:32:55
I am trying to change the font of a UIButton using Swift... myButton.font = UIFont(name: "...", 10) However .font is deprecated and I'm not sure how to change the font otherwise. Any suggestions? codester Use titleLabel instead. The font property is deprecated in iOS 3.0. It also does not work in Objective-C. titleLabel is label used for showing title on UIButton . myButton.titleLabel?.font = UIFont(name: YourfontName, size: 20) However, while setting title text you should only use setTitle:forControlState: . Do not use titleLabel to set any text for title directly. For Swift 3.0 : button

UITextView font to always be fixed size

徘徊边缘 提交于 2019-11-28 12:49: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... 回答1: Coding var fontSize : CGFloat = 12.0 // DEFAULT SIZE In your ViewDidLoad if UIDevice().userInterfaceIdiom == .phone { switch self.view.frame.size.height { case 480

iOS: UIButton titleLabel — does it do anything at all?

霸气de小男生 提交于 2019-11-28 04:58:11
I want to make a UIButton with type UIButtonTypeCustom (for the shape). I want to assign the title using button.titleLabel because I need to specify the font. The following code looks like it should work, but doesn't -- no label shows up, period. UIImage *editButtonImage = [UIImage imageNamed: @"editButton.png"]; float width = editButtonImage.size.width; float height = editButtonImage.size.height; UIButton *editButton = [UIButton buttonWithType: UIButtonTypeCustom]; editButton.frame = CGRectMake(0, 0, width, height); [editButton setBackgroundImage: editButtonImage forState:

Custom Font in ios not working

浪子不回头ぞ 提交于 2019-11-28 04:19:49
I want to use HelveticaNeue-UltraLight in my ios application. I'm adding the font file as a resource to my project and adding the "Fonts provided by application" key in the plist file. The file name is HelveticaNeue.dfont and I've added it to the key array. When I check for the available fonts I can see it now... NSArray *fonts = [UIFont fontNamesForFamilyName:@"Helvetica Neue"]; for(NSString *string in fonts){ NSLog(@"%@", string); } 1-07-08 17:32:57.866 myApp[5159:207] HelveticaNeue-Bold 2011-07-08 17:32:57.866 myApp[5159:207] HelveticaNeue-CondensedBlack 2011-07-08 17:32:57.867 myApp[5159

What happened to “HelveticaNeue-Italic” on iOS 7.0.3

左心房为你撑大大i 提交于 2019-11-28 02:53:29
Just upgraded my iPod touch to iOS 7.0.3 and "HelveticaNeue-Italic" seems to have disappeared. When I query on the phone with: [UIFont fontNamesForFamilyName:@"Helvetica Neue"] I get the following fontNames (13): HelveticaNeue-BoldItalic, HelveticaNeue-Light, HelveticaNeue-UltraLightItalic, HelveticaNeue-CondensedBold, HelveticaNeue-MediumItalic, HelveticaNeue-Thin, HelveticaNeue-Medium, HelveticaNeue-ThinItalic, HelveticaNeue-LightItalic, HelveticaNeue-UltraLight, HelveticaNeue-Bold, HelveticaNeue, HelveticaNeue-CondensedBlack When I do the same query running in the simulator I get (14):

Font color for UILabel not changing

佐手、 提交于 2019-11-27 23:20:25
问题 I am trying to display numbers on a UILabel with a bold black font and size 50. After some failed attempts I just realized that no matter what color I set the font to, it always gets set to lightGray. Is there something else I need to do other than the below? [DisplayLabel setFont:[UIFont fontWithName:[NSString stringWithUTF8String:"HelveticaNeue-Bold"] size:50]]; DisplayLabel.textColor = [UIColor brownColor]; DisplayLabel.textAlignment = NSTextAlignmentCenter; I am adding the label using the

UIFont fontWithName returns nil

冷暖自知 提交于 2019-11-27 22:05:44
问题 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",

Detect whether a font is bold/italic on iOS?

纵然是瞬间 提交于 2019-11-27 21:12:31
问题 Given a UIFont or a CTFont, how can I tell whether the font is bold/italic? 回答1: 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);