• Stars
    star
    524
  • Rank 84,541 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

AttributedLabel

Build Status Carthage compatible Version License Platform

Graph

Higher performance than UILabel.

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.

More Repositories

1

DynamicBlurView

DynamicBlurView is a dynamic and high performance UIView subclass for Blur.
Swift
967
star
2

GridView

Reusable GridView with excellent performance and customization that can be time table, spreadsheet, paging and more.
Swift
855
star
3

TableViewDragger

A cells of UITableView can be rearranged by drag and drop.
Swift
536
star
4

SimpleAlert

Customizable simple Alert and simple ActionSheet for Swift
Swift
398
star
5

PagingView

Infinite paging, Smart auto layout, Interface of similar to UIKit.
Swift
316
star
6

SpringIndicator

SpringIndicator is indicator and PullToRefresh. Inspired by Material design components.
Swift
272
star
7

Keynode

Interactive Keyboard Controller for Swift
Swift
77
star
8

NavigationNotice

Customizable and interactive animated notification UI control.
Swift
75
star
9

ProtobufExample

Example of requesting Protocol Buffers and JSON with Swift. API is Swift or Go.
Swift
67
star
10

Plan

The Plan.framework helps to keep your iOS application design clean.
Swift
36
star
11

RxDisplayLink

RxDisplayLink reactive wrapper for CADisplayLink
Swift
29
star
12

smooth_counter

Dart
24
star
13

Exclusion

Customizable URLCache.
Swift
19
star
14

MountainView

The animation curve looks like Mountain View.
Swift
14
star
15

G3JSON

Objective-C
11
star
16

gRPCExample

Swift
11
star
17

XcodeGenSample

Swift
9
star
18

InfiniteView

Swift
4
star
19

lcov_excluder

It is possible to exclude coverage by editing the contents of the lcov.info file.
Dart
3
star
20

grain

Module management library like requirejs.
JavaScript
2
star
21

CollectionViewGridLayout

How to use grid layout in UICollectionView.
Swift
2
star
22

assets

1
star