Easy to use, fast, and higher performance than UILabel.
UILabel
.This is a better performance than UILabel
and can be used like a standard UI component.
Also, Easier to use than UILabel
.
Since UIView
is inherited instead of UILabel
, there is little wasteful processing.
It uses the function of TextKit to draw characters.
However, please note that content layout is not done automatically.
If want to automatically fix the height of the content, set usesIntrinsicContentSize
to true
.
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.
!
Add the following to your Podfile
:
pod "AttributedLabel"
Add the following to your Cartfile
:
github "KyoheiG3/AttributedLabel"
Just add everything in the AttributedLabel.swift
file to your project.
var numberOfLines: Int
numberOfLines
of UILabel
.0
.var contentAlignment: AttributedLabel.ContentAlignment
left
.@IBInspectable var padding: CGFloat
lineFragmentPadding
of NSTextContainer
.0
.var font: UIFont
var lineBreakMode: NSLineBreakMode
lineBreakMode
of UILabel
.ByTruncatingTail
.@IBInspectable var textColor: UIColor?
var paragraphStyle: NSParagraphStyle?
var shadow: NSShadow?
var attributedText: NSAttributedString?
@IBInspectable var text: String?
var usesIntrinsicContentSize: Bool
false
.var preferredMaxLayoutWidth: CGFloat
override func sizeThatFits(size: CGSize) -> CGSize
sizeThatFits
of UILabel
.override func sizeToFit()
UILabel
.Follow me 🎉
Under the MIT license. See LICENSE file for details.