Skip to content
프로젝트

소개

사용하기 쉽고 빠르며 UILabel보다 성능이 뛰어납니다.

웹 및 앱 개발

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

AttributedLabel

Build Status Carthage compatible Version License Platform

Graph

Higher performance than UILabel.

Appetize's Demo

Label

Overview

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.

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 !

Requirements

  • Swift 5.0
  • iOS 7.0 or later
  • tvOS 9.0 or later

How to Install AttributedLabel

iOS 8+, tvOS

CocoaPods

Add the following to your Podfile:

pod "AttributedLabel"

Carthage

Add the following to your Cartfile:

github "KyoheiG3/AttributedLabel"

iOS 7

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

Usage

Variable

var numberOfLines: Int
  • Same as numberOfLines of UILabel.
  • Default is 0.
var contentAlignment: AttributedLabel.ContentAlignment
  • Alignment of content.
  • Default is left.
@IBInspectable 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.
@IBInspectable 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.
@IBInspectable var text: String?
  • Default is nil.
var usesIntrinsicContentSize: Bool
  • If need to use intrinsicContentSize set true.
  • Should call invalidateIntrinsicContentSize when intrinsicContentSize is cached. When text was changed for example.
  • Default is false.
var preferredMaxLayoutWidth: CGFloat
  • Support for constraint-based layout (auto layout)
  • If nonzero, this is used when determining intrinsicContentSize for multiline labels

Function

override func sizeThatFits(size: CGSize) -> CGSize
  • Same as sizeThatFits of UILabel.
override func sizeToFit()
  • Fit like UILabel.

Author

Kyohei Ito

Follow me 🎉

LICENSE

Under the MIT license. See LICENSE file for details.

관련 프로젝트 살펴보기

불러오는 중…