I tried to create a Text View using attributedString. I want to set the line height using paragraphStyle and return the Text, but paragraphStyle is not being applied. Why is that?
extension Text {
init?(_ content: String, font: StyleType, color: Color = .ppBlack) {
var attributedString = AttributedString(content)
attributedString.font = Font.custom(font.fontWeight, fixedSize: font.fontSize)
attributedString.foregroundColor = color
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.minimumLineHeight = 16
paragraphStyle.maximumLineHeight = 16
paragraphStyle.lineSpacing = 0
attributedString.mergeAttributes(.init([.paragraphStyle: paragraphStyle]))
self = Text(attributedString)
}
}