48 lines
1.3 KiB
Swift
48 lines
1.3 KiB
Swift
//
|
|
// gp_label.swift
|
|
// Hthik
|
|
//
|
|
// Created by 忆海16 on 2024/5/31.
|
|
// Copyright © 2024 Hthik. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
|
|
class LabelModifier {
|
|
|
|
// 修改标签的文本颜色
|
|
static func changeTextColor(of label: UILabel, to color: UIColor) {
|
|
label.textColor = color
|
|
}
|
|
|
|
// 修改标签的背景颜色
|
|
static func changeBackgroundColor(of label: UILabel, to color: UIColor) {
|
|
label.backgroundColor = color
|
|
}
|
|
|
|
// 修改标签的文本和背景颜色
|
|
static func changeColors(of label: UILabel, textColor: UIColor, backgroundColor: UIColor) {
|
|
label.textColor = textColor
|
|
label.backgroundColor = backgroundColor
|
|
}
|
|
|
|
// 修改标签的字体
|
|
static func changeFont(of label: UILabel, to font: UIFont) {
|
|
label.font = font
|
|
}
|
|
|
|
// 修改标签的文本
|
|
static func changeText(of label: UILabel, to text: String) {
|
|
label.text = text
|
|
}
|
|
|
|
// 修改标签的所有属性
|
|
static func changeAttributes(of label: UILabel, textColor: UIColor, backgroundColor: UIColor, font: UIFont, text: String) {
|
|
label.textColor = textColor
|
|
label.backgroundColor = backgroundColor
|
|
label.font = font
|
|
label.text = text
|
|
}
|
|
}
|