iOS 標簽:AttributedLabel

ynnc 9年前發布 | 12K 次閱讀 iOS開發 移動開發 AttributedLabel

AttributedLabel 比 UILabel 更容易使用,更快,性能更好。

Graph

Graph

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 yourPodfile:

pod "AttributedLabel" use_frameworks!

Note: theuse_frameworks!is required for pods made in Swift.

Carthage

Add the following to yourCartfile:

github "KyoheiG3/AttributedLabel"

iOS 7

Just add everything in theAttributedLabel.swiftfile to your project.

Usage

import

If target is ios8.0 or later, please import theAttributedLabel.

import AttributedLabel

Variable

var numberOfLines: Int
  • Same asnumberOfLinesofUILabel.
  • Default is0.
var contentAlignment: AttributedLabel.ContentAlignment
  • Alignment of content.
  • Default isLeft.
var font: UIFont
  • Text font.
  • Default is system font 17 plain.
var lineBreakMode: NSLineBreakMode
  • Same aslineBreakModeofUILabel.
  • Default isByTruncatingTail.
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 assizeThatFitsofUILabel.
override func sizeToFit()
  • Same assizeToFitofUILabel.
  • Autolayout doesn't work withsizeToFit.

項目主頁:http://www.baiduhome.net/lib/view/home/1438093819675

 本文由用戶 ynnc 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!