UIFont with a custom host?

I would like to use a system font, but with a custom leading, but the main property of UIFont is read-only. Is there a way to create a system font with a custom leading value?

I am trying to display multiple lines with a UILabel, but the default is too narrow. (\ n \ n is too wide)

If there is no way, I need to create some UILabels, but it went a little too far.

+3
source share
3 answers

I think you cannot do this. UIFont is pretty much limited.

, , UILabels. – componentsSeparatedByString: UIKit NSString: – drawAtPoint:withFont:.

, - . .

+2

UILabel. text attributedText. lineSpacing, . :

NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineSpacing = -4;

NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:yourStringHere];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, titleText.length)];
yourUILabel.attributedText = attributedString;
+1

This can be done by breaking the user category into UIFont and replacing the property to load with the user setter. I'm still trying to do this.

-2
source

Source: https://habr.com/ru/post/1705182/


All Articles