Swiftはこんな基本的なのを用意していない・・・・。
仕方ないので拡張する。
extension UILabel { func applyLineHeight(_ lineHeight: CGFloat) { if let text = self.text, let font = self.font { // NSMutableAttributedStringを使用して、テキストのスタイルを定義します。 let attributedString = NSMutableAttributedString(string: text) let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.lineHeightMultiple = lineHeight paragraphStyle.alignment = self.textAlignment // 属性をNSAttributedStringKeyとともに適用します。 attributedString.addAttribute(.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: text.count)) attributedString.addAttribute(.font, value: font, range: NSRange(location: 0, length: text.count)) // UILabelにNSAttributedStringを設定します。 self.attributedText = attributedString } } }