uifont

UIButton Custom font issue

老子叫甜甜 提交于 2020-01-25 07:07:25
问题 I have added a custom font in to my application and i set that custom font for some of the buttons by sub classing the custom font,in xib custom font set perfectly but while execute in device the font auto adjust to upside in all the button. Here is my custom font sub class code. @interface ButtonWithBebasNeueFont : UIButton @end @implementation ButtonWithBebasNeueFont - (void)awakeFromNib { [super awakeFromNib]; self.titleLabel.font = [UIFont fontWithName:@"BebasNeue" size:self.titleLabel

Toggle selectedRange attributes in UITextView

£可爱£侵袭症+ 提交于 2020-01-22 02:23:25
问题 I have created a button that I want to check if text is selected then if so toggle bold and unbold over the selectedRange when tapped. At the moment my code will just change the selectedRange to bold and I can't undo it or check if there is a selection. How can I achieve this? func bold() { if let textRange = selectedRange { let attributes = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 17, weight: UIFont.Weight.bold)] noteContents.textStorage.addAttributes(attributes as

Issues with custom font in iOS

烈酒焚心 提交于 2020-01-21 06:04:30
问题 I followed the steps outlined in various locations using the UIAppFonts property list key. I'm using the Aller Light font. I've added it as a resource, added the font name correctly in the info property list, and am now attempting to use it, however every attempt to do so results in the default font being displayed. So far I've tried: [leader setFont:[UIFont fontWithName:@"Aller Light" size:20.0]]; [leader setFont:[UIFont fontWithName:@"AllerLight" size:20.0]]; [leader setFont:[UIFont

Set custom font

浪尽此生 提交于 2020-01-15 11:02:53
问题 Here is how I set custom font in my app [self.titleLabel setFont:[UIFont fontWithName:@"FontName" size:self.font.pointSize]]; I get font is deprecated. How to fix this ? //EDIT UIButtonCustom.h #import <Foundation/Foundation.h> @interface UIButtonCustom : UIButton @end UIButtonCustom.m -(void)awakeFromNib { [super awakeFromNib]; [self.titleLabel setFont:[UIFont fontWithName:@"FontName" size:self.font.pointSize]]; } 回答1: Since you did not say what type of class self is I am not exactly sure

Set custom font

北城余情 提交于 2020-01-15 11:01:03
问题 Here is how I set custom font in my app [self.titleLabel setFont:[UIFont fontWithName:@"FontName" size:self.font.pointSize]]; I get font is deprecated. How to fix this ? //EDIT UIButtonCustom.h #import <Foundation/Foundation.h> @interface UIButtonCustom : UIButton @end UIButtonCustom.m -(void)awakeFromNib { [super awakeFromNib]; [self.titleLabel setFont:[UIFont fontWithName:@"FontName" size:self.font.pointSize]]; } 回答1: Since you did not say what type of class self is I am not exactly sure

iOS UIFont caching?

孤人 提交于 2020-01-12 13:51:21
问题 I am trying to figure out if I should cache [UIFont fontWithName:@"myfont" size:24]. I am reusing this font in many places. I am wondering if iOS is already caching this for me because font caching is very common at OS level. Can someone comment on this? Thanks. 回答1: Last time I checked, system fonts were cached (i.e. calling [UIFont systemFontOfSize:foo] twice returned you the same object). I'm not sure how often the cache flushes, but it would seem very silly to not cache fonts, since they

iOS UIFont caching?

六月ゝ 毕业季﹏ 提交于 2020-01-12 13:50:14
问题 I am trying to figure out if I should cache [UIFont fontWithName:@"myfont" size:24]. I am reusing this font in many places. I am wondering if iOS is already caching this for me because font caching is very common at OS level. Can someone comment on this? Thanks. 回答1: Last time I checked, system fonts were cached (i.e. calling [UIFont systemFontOfSize:foo] twice returned you the same object). I'm not sure how often the cache flushes, but it would seem very silly to not cache fonts, since they

Determine if unicode character has a glyph in UIFont

一笑奈何 提交于 2020-01-12 10:41:54
问题 I want to find out if a certain unicode character has a glyph representation even if by a cascading font. For example, let's say I am using UIFont.systemFont(withSize:18) and a string \u{1CDA} and would like to find out if this font will display the graphical representation of this character, and not a default question mark representation (ie there's no graphical representation, even by the supporting cascade fonts). 回答1: This works for me. Swift 3, XCode 8.6 version: import UIKit import

How can I calculate font size for my UILabel?

断了今生、忘了曾经 提交于 2020-01-06 04:01:05
问题 I have a UILabel measuring 984x728 px with variable text. How can I calculate the maximum font size to fit the UILabel ? 回答1: Create a font larger than you would ever want (48 points is probably good). Then use this: CGFloat maxFontSize; [string sizeWithFont:font minFontSize:0 actualFontSize:&maxFontSize forWidth:maxWidth lineBreakMode: UILineBreakModeClip]; maxFontSize will hold the largest size less than 48 and greater than 0 that will fit within maxWidth . 来源: https://stackoverflow.com

Is there a way to add custom fonts to Xcode to be available from a storyboard? [duplicate]

别等时光非礼了梦想. 提交于 2020-01-05 10:13:09
问题 This question already has answers here : Designing labels/text views with custom fonts in Interface Builder (8 answers) Closed 5 years ago . I know how to add custom font files to be shipped with an iOS app. I can then customize the label font from code using code like this : UIFont* font = [UIFont fontWithName:@"League Gothic" size:42]; self.topLabel.font = font; My concern is that such customization will "infect" all of the project and may require some significant rework later on. Is there