Left tab is customizable label. The center tab AttributedLabel So fast. Right tab is UILabel So slow. Fast more than 10 times from 5 times.
- use the UIlabel
- use the AttributedLabel
Add the following to your Podfile
:
pod "AttributedLabel"
use_frameworks!
Note: the use_frameworks!
is required for pods made in Swift.
Add the following to your Cartfile
:
github "KyoheiG3/AttributedLabel"
Just add everything in the AttributedLabel.swift
file to your project.
If target is ios8.0 or later, please import the AttributedLabel
.
import AttributedLabel
var numberOfLines: Int
- Same as
numberOfLines
ofUILabel
. - Default is
0
.
var contentAlignment: AttributedLabel.ContentAlignment
- Alignment of content.
- Default is
Left
.
var padding: CGFloat
lineFragmentPadding
ofNSTextContainer
.- default is
0
.
var font: UIFont
- Text font.
- Default is system font 17 plain.
var lineBreakMode: NSLineBreakMode
- Same as
lineBreakMode
ofUILabel
. - Default is
ByTruncatingTail
.
var textColor: UIColor?
- Default is nil (text draws black).
var paragraphStyle: NSParagraphStyle?
- Default is nil.
var shadow: NSShadow?
- Default is nil.
var attributedText: NSAttributedString?
- Default is nil.
var text: String?
- Default is nil.
override func sizeThatFits(size: CGSize) -> CGSize
- Same as
sizeThatFits
ofUILabel
.
override func sizeToFit()
- Same as
sizeToFit
ofUILabel
. - Autolayout doesn't work with
sizeToFit
.
Under the MIT license. See LICENSE file for details.