uifont

get font-weight of an uitextview

北城以北 提交于 2021-02-08 08:35:17
问题 I want to resize the font-size in some UITextViews. That works fine with an outlet collection and this code: for (UITextView *view in self.viewsToResize) { if ([view respondsToSelector:@selector(setFont:)]) { [view setFont:[UIFont systemFontOfSize:view.font.pointSize + 5]]; } } But my problem is, that not every textView uses the systemFont in normal weight, some of them are in bold weight. Is it possible to get the font-weight? With a po view.font in the debug area I can see everything I need

How can I find the UIFont pointSize necessary to get a desired lineHeight or other metric?

家住魔仙堡 提交于 2021-01-28 03:02:44
问题 You can ask a UIFont instance for its lineHeight metric: UIFont *const font = [UIFont systemFontOfSize: 10]; CGFloat lineHeight = [font lineHeight]; If I want a particular lineHeight, (20, say), how can I create a UIFont with that size? 回答1: Answer My limited analysis suggests, surprisingly to me, that linear interpolation can be used. Here's a category on UIFont that will do what's needed: @interface UIFont (FontWithLineHeight) +(UIFont*) systemFontWithLineHeight: (CGFloat) lineHeight; @end

Convert from SwiftUI.Font to UIFont

一世执手 提交于 2020-08-01 04:01:15
问题 I have a UIViewRepresentable with a UITextView and I want to set the font on the UITextView using the Font from the SwiftUI environment. I just need a simple init like: UIFont(_ swiftUIFont: Font) But I can't find any such thing. And the Font type doesn't seem to have any information I can use to try to implement one. Anyone know of a way to convert between the two? 回答1: Font seems to be based on top of Core Text , rather than on UIKit. You could create a shared CTFont , and share it between

Convert from SwiftUI.Font to UIFont

二次信任 提交于 2020-08-01 03:57:10
问题 I have a UIViewRepresentable with a UITextView and I want to set the font on the UITextView using the Font from the SwiftUI environment. I just need a simple init like: UIFont(_ swiftUIFont: Font) But I can't find any such thing. And the Font type doesn't seem to have any information I can use to try to implement one. Anyone know of a way to convert between the two? 回答1: Font seems to be based on top of Core Text , rather than on UIKit. You could create a shared CTFont , and share it between

Enable/Disable font scaling impact by IOS on my application

∥☆過路亽.° 提交于 2020-06-18 02:38:06
问题 I am new to IOS development and working on an application whose font size doesn't get affected by a change in the font size of the phone, which is set by the user, while the font size of other apps installed on my phone gets change. For example if changed from General->Accessibility->Large Text (On) it impacts all the application except mine. Now as per the requirement of our users it should change the size of our application as well, does anybody know how to enable our disable this font

How can I get weight of a UILabel?

故事扮演 提交于 2020-05-14 20:05:07
问题 User from storyboard or programatically can set font weight as regular, semi bold etc. I want to read weight for any font label. I tried po label.font.description and font-weight is there and but there is no exposed variable to get weight from font. Is it possible? 回答1: To get the font weight string name, use the font descriptor and pass in the face attribute. Swift 4.2 let font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.bold) let face = font.fontDescriptor.object(forKey: