• Stars
    star
    1,104
  • Rank 40,416 (Top 0.9 %)
  • Language
    Swift
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated 4 months ago

Reviews

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

Repository Details

Swift TTTAttributedLabel replacement

Nantes 🥕

CI Status CocoaPods Compatible Carthage Compatible

This library is a Swift port/fork of the popular Objective-C library TTTAttributedLabel. Much ❤️ and credit goes to Mattt for creating such a great UILabel replacement library.

Nantes is a pure-Swift UILabel replacement. It supports attributes, data detectors, and more. It also supports link embedding automatically and with NSTextCheckingTypes.

Come build awesome things with us here at Instacart!

Requirements

  • iOS 8.0+
  • Swift 4.2

Installation

Nantes is available through Carthage. To install it, add the following line to your Cartfile:

github "instacart/nantes"

CocoaPods

Nantes is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Nantes'

Communication

If you need help, feel free to open an issue. Please search before opening one, someone might have run into something similar.

Contributing

Opening a pull request is the best way to get something fixed. If you need help, feel free to open an issue, hopefully someone can help you out with a problem you're running into.

Author

chansen22, [email protected]

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Getting Started

Check out Nantes in the Example directory for more examples.

import Nantes

let label: NantesLabel = .init(frame: .zero)
label.attributedTruncationToken = NSAttributedString(string: "... more")
label.numberOfLines = 3
label.labelTappedBlock = {
  label.numberOfLines = label.numberOfLines == 0 ? 3 : 0 // Flip between limiting lines and not

  UIView.animateWithDuration(0.2, animations: {
    self.view.layoutIfNeeded()
  })
}

label.text = "Nantes label is great! Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus ac urna et ante lobortis varius. Nunc rhoncus enim vitae sem commodo sodales. Morbi id augue id augue finibus tincidunt. Cras ac massa nisi. Maecenas elementum vitae elit eu mattis. Duis pretium turpis ut justo accumsan molestie. Mauris elit elit, maximus eu risus sed, vestibulum sodales enim. Sed porttitor vestibulum tincidunt. Maecenas mollis tortor quam, sed porta justo rhoncus id. Phasellus vitae augue tempor, luctus metus sit amet, dictum urna. Morbi sit amet feugiat purus. Proin vitae finibus lectus, eu gravida erat."
view.addSubview(label)

let linkLabel: NantesLabel = .init(frame: .zero)
linkLabel.delegate = self // NantesLabelDelegate
linkLabel.linkAttributes = [NSAttributedString.Key.foregroundColor: UIColor.green]
linkLabel.text = "https://www.instacart.com"
view.addSubview(linkLabel)

// Link handling

func attributedLabel(_ label: NantesLabel, didSelectLink link: URL) {
  print("Tapped link: \(link)")
}

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

lore

Lore makes machine learning approachable for Software Engineers and maintainable for Machine Learning Researchers
Python
1,549
star
2

truetime-android

Android NTP time library. Get the true current time impervious to device clock time changes
Kotlin
1,385
star
3

makara

A Read-Write Proxy for Connections; Also provides an ActiveRecord adapter.
Ruby
902
star
4

TrueTime.swift

NTP library for Swift and Objective-C. Get the true time impervious to device clock changes.
Swift
576
star
5

wilson_score

Simple, dependency-free Wilson score
Ruby
154
star
6

formula

A functional reactive framework for managing state and side effects based on RxJava.
Kotlin
147
star
7

ohmycron

Run cron jobs in a standardized environment with logs and locking
Shell
138
star
8

ahab

Docker event handling with Python
Python
137
star
9

amountable

An easy and transparent way to attach, manage and sum Money fields to your ActiveRecord models.
Ruby
122
star
10

jardin-archived

A pandas.DataFrame-based ORM.
Python
85
star
11

Snacks

The Instacart Component Library
JavaScript
79
star
12

redux-rails

Redux and your server talking without fuss.
JavaScript
56
star
13

arn

A Python library for parsing AWS ARNs.
Python
44
star
14

ahoy-android

Android attribution library build on top of Ahoy for Ruby on Rails.
Java
19
star
15

cwam

CloudWatch Alarms Manager. Easy way to create default CloudWatch Alarms for AWS resources.
Python
19
star
16

instacart-android-pp-sandbox

Android challenge sandbox
Kotlin
9
star
17

aws-scripts-mon

[TO BE DELETED] Clone of AWS Cloudwatch Monitor Scripts + report inodes
Perl
4
star
18

redux-rails-resource

Simple interface of redux-rails resources for react components
JavaScript
3
star
19

OmniAX

UIAccessibility wrapper
Swift
2
star
20

instacart-ios-pp-starter

Starter app to give candidates starting on pair programming exercise
Swift
2
star
21

ExploreRxSwift

Swift
2
star
22

cloudflare-rails

Ruby
2
star
23

SocketLogger.swift

Lightweight, flexible logging utility compatible with any socket-based syslog service.
Swift
2
star
24

optplayground

A playground for optimization!
Python
1
star
25

instacart-android-pp-starter

Starter app to give candidates starting on pair programming exercise
Java
1
star
26

activerecord-import_with_callbacks

A library for bulk importing data using ActiveRecord
Ruby
1
star