-
Notifications
You must be signed in to change notification settings - Fork 0
/
UILabel Extension.swift
41 lines (31 loc) · 983 Bytes
/
UILabel Extension.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// File.swift
// InTheBlack
//
// Created by Nathan Mann on 5/14/15.
// Copyright (c) 2015 Nathan Mann. All rights reserved.
//
import Foundation
import UIKit
extension UILabel {
convenience init(text: String?, font: UIFont?, textColor: UIColor?, backgroundColor: UIColor?, textAlignment: NSTextAlignment? ) {
self.init()
self.text = text
self.backgroundColor = backgroundColor
if let font = font {
self.font = font
}
if let textColor = textColor {
self.textColor = textColor
}
if let textAlignment = textAlignment {
self.textAlignment = textAlignment
}
}
convenience init(font: UIFont, numberOfLines: Int = 0, lineBreakMode: NSLineBreakMode = .byWordWrapping) {
self.init()
self.font = font
self.numberOfLines = numberOfLines
self.lineBreakMode = lineBreakMode
}
}