Skip to content

Easy to use, fast, and higher performance than UILabel.

License

Notifications You must be signed in to change notification settings

marty-suzuki/AttributedLabel

 
 

Repository files navigation

AttributedLabel

Carthage compatible Version License Platform

Graph

Higher performance than UILabel.

Label

Customization is easy.

Customize

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

UILabel

  • use the AttributedLabel

AttributedLabel

How to Install AttributedLabel

iOS 8+

Cocoapods

Add the following to your Podfile:

pod "AttributedLabel"
use_frameworks!

Note: the use_frameworks! is required for pods made in Swift.

Carthage

Add the following to your Cartfile:

github "KyoheiG3/AttributedLabel"

iOS 7

Just add everything in the AttributedLabel.swift file to your project.

Usage

import

If target is ios8.0 or later, please import the AttributedLabel.

import AttributedLabel

Variable

var numberOfLines: Int
  • Same as numberOfLines of UILabel.
  • Default is 0.
var contentAlignment: AttributedLabel.ContentAlignment
  • Alignment of content.
  • Default is Left.
var padding: CGFloat
  • lineFragmentPadding of NSTextContainer.
  • default is 0.
var font: UIFont
  • Text font.
  • Default is system font 17 plain.
var lineBreakMode: NSLineBreakMode
  • Same as lineBreakMode of UILabel.
  • 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.

Function

override func sizeThatFits(size: CGSize) -> CGSize
  • Same as sizeThatFits of UILabel.
override func sizeToFit()
  • Same as sizeToFit of UILabel.
  • Autolayout doesn't work with sizeToFit.

LICENSE

Under the MIT license. See LICENSE file for details.

About

Easy to use, fast, and higher performance than UILabel.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 92.7%
  • Ruby 3.8%
  • Objective-C 3.5%