Merge branch 'bugfix/TextStyleLabelAttribute' into 'develop'
fixed bug in TextStyle Attribute dealing with lineHeight and baseline See merge request BPHV_MIPS/vds_ios!306
This commit is contained in:
commit
2febe4595c
@ -63,9 +63,7 @@ public struct TextStyleLabelAttribute: LabelAttributeModel {
|
||||
|
||||
//set lineHeight
|
||||
if textStyle.lineHeight > 0.0 {
|
||||
let lineHeight = textStyle.lineHeight
|
||||
let adjustment = lineHeight > textStyle.font.lineHeight ? 2.0 : 1.0
|
||||
let baselineOffset = (lineHeight - textStyle.font.lineHeight) / 2.0 / adjustment
|
||||
let lineHeight = textStyle.lineHeight + abs(textStyle.edgeInsets.bottom) + abs(textStyle.edgeInsets.top)
|
||||
let paragraph = NSMutableParagraphStyle().with {
|
||||
$0.maximumLineHeight = lineHeight
|
||||
$0.minimumLineHeight = lineHeight
|
||||
@ -74,7 +72,6 @@ public struct TextStyleLabelAttribute: LabelAttributeModel {
|
||||
}
|
||||
attributedString.removeAttribute(.baselineOffset, range: range)
|
||||
attributedString.removeAttribute(.paragraphStyle, range: range)
|
||||
attributedString.addAttribute(.baselineOffset, value: baselineOffset, range: range)
|
||||
attributedString.addAttribute(.paragraphStyle, value: paragraph, range: range)
|
||||
|
||||
} else if textPosition != .left {
|
||||
@ -87,3 +84,4 @@ public struct TextStyleLabelAttribute: LabelAttributeModel {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user