From d515d762cb9e914962a817f0c1a5ff02df2b721c Mon Sep 17 00:00:00 2001 From: Joon Baek Date: Sun, 3 Sep 2023 03:57:10 +0900 Subject: [PATCH] =?UTF-8?q?[Add]=20#214=20-=20setDefaultAttributes=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Global/Extensions/UILabel+Extension.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pophory-iOS/Global/Extensions/UILabel+Extension.swift b/pophory-iOS/Global/Extensions/UILabel+Extension.swift index 0f9fd266..810b3386 100644 --- a/pophory-iOS/Global/Extensions/UILabel+Extension.swift +++ b/pophory-iOS/Global/Extensions/UILabel+Extension.swift @@ -8,6 +8,20 @@ import UIKit extension UILabel { + func setDefaultAttributes(lineHeight: CGFloat, font: UIFont) -> [NSAttributedString.Key: Any] { + let paragraphStyle = NSMutableParagraphStyle() + paragraphStyle.maximumLineHeight = lineHeight + paragraphStyle.minimumLineHeight = lineHeight + + let defaultAttributes: [NSAttributedString.Key: Any] = [ + .paragraphStyle: paragraphStyle, + .baselineOffset: (lineHeight - font.lineHeight) / 4, + .font: font, + .foregroundColor: UIColor.black + ] + + return defaultAttributes + } func setAttributedText( text: String,