Closed Chunngai closed 5 months ago
@Chunngai, you may use matchTextExact
with insets
to get around this issue. Using the following style, you can achive the output below:
let style = BackgroundStyle(color: .green, roundedCornerStyle: .absolute(value: 5), border: BorderStyle(lineWidth: 1, color: UIColor.blue),
shadow: ShadowStyle(color: .red, offset: CGSize(width: 2, height: 2), blur: 1),
heightMode: .matchTextExact, insets: UIEdgeInsets(top: -5, left: 0, bottom: -5, right: 0))
If you wish for the backgrounds to be merged as shown in the article, you can also use matchLine
for heightMode
.
I'll be fixing the matchText
option in a future release to work better with lineSpacing
. The key difference in matchText
and matchTextExact
is that the matchTextExact
assumes the exact text height by default where as matchText
keeps a little padding all around based on iOS string boundingRect logic. Since similar output can be achieved by matchTextExact
with insets
, I may also consider dropping matchText
altogether.
@rajdeep Thanks, the problem was solved.
When testing the feature of background colour with rounded corners (as introduced here), I found two issues with a non-zero line spacing, as shown in the attached screenshot.
Issues
Reproduction
setup()
method ofExampleApp/ExampleApp/AdvancedFeatures/CommandsExampleViewController
, I addedtypingAttributes
as follows:execute()
method ofExampleApp/ExampleApp/Commands/TextBlockCommand.swift
, I updated the background style as follows:Any ideas to fix it?
The first problem may be caused by the code for
.matchText
in thedrawBackground(forGlyphRange:at:)
method of the customizedLayoutManager
.