You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
//
|
|
// UIButton_Ext.swift
|
|
// GME Remit
|
|
//
|
|
// Created by InKwon James Kim on 2019/11/28.
|
|
// Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
extension UILabel {
|
|
func adjustsFontSizeToFitWidth(_ boolean: Bool, scale: CGFloat) {
|
|
minimumScaleFactor = scale
|
|
adjustsFontSizeToFitWidth = boolean
|
|
}
|
|
|
|
func setLineSpacing(lineSpacing: CGFloat = 0.0, lineHeightMultiple: CGFloat = 0.0) {
|
|
|
|
guard let labelText = self.text else { return }
|
|
|
|
let paragraphStyle = NSMutableParagraphStyle()
|
|
paragraphStyle.lineSpacing = lineSpacing
|
|
paragraphStyle.lineHeightMultiple = lineHeightMultiple
|
|
|
|
let attributedString:NSMutableAttributedString
|
|
if let labelattributedText = self.attributedText {
|
|
attributedString = NSMutableAttributedString(attributedString: labelattributedText)
|
|
} else {
|
|
attributedString = NSMutableAttributedString(string: labelText)
|
|
}
|
|
|
|
attributedString.addAttribute(
|
|
NSAttributedString.Key.paragraphStyle,
|
|
value:paragraphStyle,
|
|
range: NSMakeRange(0, attributedString.length)
|
|
)
|
|
|
|
self.attributedText = attributedString
|
|
}
|
|
|
|
}
|