line-spacing

UItextView background colours Linespacing area too

半城伤御伤魂 提交于 2020-01-01 07:17:21
问题 I am trying to replicate the text highlight (Not Search Text Highlight) in my UIText View. But I am Stuck with the colouring in the linespacing as well. How Can I rectify this ? Current situation: Desired Outcome: I have added the following attributes to my UiTextview's Attributed Text For Paragraph Line Spacing I have used the following let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.lineSpacing = 10 For Other Attributes I have used the following verseAttributes :

How to Increase Line spacing in UILabel in Swift

你说的曾经没有我的故事 提交于 2019-12-28 04:54:06
问题 I have a label which has few lines of text and I want to increase the spacing between the lines. There are similar questions asked by others but the solutions don't solve my problems. Also my label may or may not contain paragraphs. I am new to Swift . Is there a solution using storyboard? Or only through NSAttributedString its possible? 回答1: Programatically add LineSpacing to your UILabel using following snippet. Earlier Swift version let attributedString = NSMutableAttributedString(string:

How to control the line spacing in UILabel

爷,独闯天下 提交于 2019-12-17 03:21:45
问题 Is it possible to reduce the gap between text when put in multiple lines in a UILabel ? We can set the frame, font size and # of lines. I want to reduce the gap between the two lines in that label. 回答1: I thought about adding something new to this answer, so I don't feel as bad... Here is a Swift answer: import Cocoa let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.lineSpacing = 40 let attrString = NSMutableAttributedString(string: "Swift Answer") attrString.addAttribute(

UItextView background colours Linespacing area too

纵饮孤独 提交于 2019-12-03 21:42:00
I am trying to replicate the text highlight (Not Search Text Highlight) in my UIText View. But I am Stuck with the colouring in the linespacing as well. How Can I rectify this ? Current situation: Desired Outcome: I have added the following attributes to my UiTextview's Attributed Text For Paragraph Line Spacing I have used the following let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.lineSpacing = 10 For Other Attributes I have used the following verseAttributes : [NSAttributedStringKey : Any] = [ NSAttributedStringKey(rawValue : NSAttributedStringKey.font.rawValue) : UIFont

Objective C - UILabel multiline vertical gap height

末鹿安然 提交于 2019-12-01 09:05:40
问题 I have a multiline UILabel that can take a maximum of 3 lines. i.e message.numberOfLines = 3; Everything works fine, but how can I set the vertical gap between the lines? e.g between line 1 and line 2 etc? Please enlight, Tee 回答1: I haven't been able to find a way to adjust the spacing between lines. The font property of UILabel has a number of read-only properties, so that won't help. I've resorted to draw my own text if I want to change the line spacing. I use NSString's -drawAtPoint and

Core Text - NSAttributedString line height done right?

萝らか妹 提交于 2019-11-29 20:25:41
I'm completely in the dark with Core Text's line spacing. I'm using NSAttributedString and I specify the following attributes on it: - kCTFontAttributeName - kCTParagraphStyleAttributeName From this the CTFrameSetter gets created and drawn to context. In the paragraph style attribute I'd like to specify the height of the lines. When I use kCTParagraphStyleSpecifierLineHeightMultiple each line receives padding at the top of the text, instead of the text being displayed in the middle of this height. When I use kCTParagraphStyleSpecifierLineSpacing a padding is added to the bottom of the text.

Core Text - NSAttributedString line height done right?

↘锁芯ラ 提交于 2019-11-28 15:56:40
问题 I'm completely in the dark with Core Text's line spacing. I'm using NSAttributedString and I specify the following attributes on it: - kCTFontAttributeName - kCTParagraphStyleAttributeName From this the CTFrameSetter gets created and drawn to context. In the paragraph style attribute I'd like to specify the height of the lines. When I use kCTParagraphStyleSpecifierLineHeightMultiple each line receives padding at the top of the text, instead of the text being displayed in the middle of this

How to Increase Line spacing in UILabel in Swift

久未见 提交于 2019-11-27 18:16:57
I have a label which has few lines of text and I want to increase the spacing between the lines. There are similar questions asked by others but the solutions don't solve my problems. Also my label may or may not contain paragraphs. I am new to Swift . Is there a solution using storyboard? Or only through NSAttributedString its possible? Programatically add LineSpacing to your UILabel using following snippet. Earlier Swift version let attributedString = NSMutableAttributedString(string: "Your text") // *** Create instance of `NSMutableParagraphStyle` let paragraphStyle =

Set UILabel line spacing

流过昼夜 提交于 2019-11-26 19:28:16
How can I modify the gap between lines (line spacing) in a multiline UILabel ? Edit: Evidently NSAttributedString will do it, on iOS 6 and later. Instead of using an NSString to set the label's text, create an NSAttributedString , set attributes on it, then set it as the .attributedText on the label. The code you want will be something like this: NSMutableAttributedString* attrString = [[NSMutableAttributedString alloc] initWithString:@"Sample text"]; NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; [style setLineSpacing:24]; [attrString addAttribute

How to control the line spacing in UILabel

对着背影说爱祢 提交于 2019-11-26 15:37:54
Is it possible to reduce the gap between text when put in multiple lines in a UILabel ? We can set the frame, font size and # of lines. I want to reduce the gap between the two lines in that label. Mazyod I thought about adding something new to this answer, so I don't feel as bad... Here is a Swift answer: import Cocoa let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.lineSpacing = 40 let attrString = NSMutableAttributedString(string: "Swift Answer") attrString.addAttribute(.paragraphStyle, value:paragraphStyle, range:NSMakeRange(0, attrString.length)) var tableViewCell =