• Stars
    star
    461
  • Rank 95,028 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 3 years ago

Reviews

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

Repository Details

A simple UILabel subclass that shows a tappable link if the content doesn't fit the specified number of lines

ExpandableLabel

ExpandableLabel is a simple UILabel subclass that shows a tappable link if the content doesn't fit the specified number of lines. If touched, the label will expand to show the entire content.

Maintenance

This project is passively maintained. Pull Requests are welcome, will be reviewed, merged and released as new CocoaPod version as long as they don't break things. Nevertheless we don't have the resources to actively continue development, answer issues or give support for integration.

Installation

CocoaPods

Add this to your Podfile:

pod "ExpandableLabel"

Carthage

Add this to your Cartfile:

github "apploft/ExpandableLabel"

Run carthage to build the framework and drag the built ExpandableLabel.framework into your Xcode project.

Usage

Using ExpandableLabel is very simple. In your storyboard, set the custom class of your UILabel to ExpandableLabel and set the desired number of lines (for the collapsed state):

Note: In Carthage, set Module to ExpandableLabel.

expandableLabel.numberOfLines = 3

Apart from that, one can modify the following settings:

delegate

Set a delegate to get notified in case the link has been touched.

collapsed

Set true if the label should be collapsed or false for expanded.

expandableLabel.collapsed = true
collapsedAttributedLink

Set the link name (and attributes) that is shown when collapsed.

expandableLabel.collapsedAttributedLink = NSAttributedString(string: "Read More")
expandedAttributedLink

Set the link name (and attributes) that is shown when expanded. It is optional and can be nil.

expandableLabel.expandedAttributedLink = NSAttributedString(string: "Read Less")
setLessLinkWith(lessLink: String, attributes: [String: AnyObject], position: NSTextAlignment?)

Setter for expandedAttributedLink with caption, String attributes and optional horizontal alignment as NSTextAlignment. If the parameter position is nil, the collapse link will be inserted at the end of the text.

expandableLabel.setLessLinkWith(lessLink: "Close", attributes: [NSForegroundColorAttributeName:UIColor.red], position: nil)

ellipsis

Set the ellipsis that appears just after the text and before the link.

expandableLabel.ellipsis = NSAttributedString(string: "...")

License

ExpandableLabel is available under the MIT license. See the LICENSE file for more info.

More Repositories

1

APLExpandableCollectionView

UICollectionView subclass with vertically expandable and collapsible sections
Objective-C
110
star
2

APLSlideMenu

Sliding Hamburger Menu like the one in the Facebook App
Objective-C
43
star
3

APLKeyboardControls

inputAccesoryView above the keyboard with done button and optional previous and next buttons
Objective-C
28
star
4

APLFacebookProxyActivity

A proxy UIActivity to use when Facebook account has not been set up yet in iOS Settings
Objective-C
12
star
5

BundleFileUpdater

Deliver your iOS or OS X app with up-to-date local resource files and update them dynamically from a remote url
Swift
9
star
6

APLTextView

A text view allowing to set a placeholder text just like for UILabel etc. In addition you can set a max character count. The text view will accept only the specified number of characters as input in this case. The remaining number of characters the user is able to enter will be displayed on the bottom right corner of the text view.
Objective-C
6
star
7

APLTextField

Advanced text field with the possibility to be connected to a picker
Objective-C
5
star
8

APLSearchBar

UISearchBar subclass with extended UISearchBarDelegate protocol
Objective-C
4
star
9

APLObject

NSObject subclass with automatic debugDescription
Objective-C
4
star
10

APLPageViewControllerDataSource

APLPageViewControllerDataSource is an array based data source for UIPageViewController.
Objective-C
4
star
11

APLNetworkLayer

APLNetworkLayer is a convenient interface for Apple's network framework that provides commonly used features.
Swift
3
star
12

NSArray-SafeAccess

Avoid NSRangeException when dealing with NSArray
Ruby
3
star
13

APLWKWebView

Objective-C
3
star
14

UIViewInspectable

UIView extension for setting cornerRadius, borderWidth or borderColor in Interface Builder as IBInspectable
Objective-C
3
star
15

AFOAuth2Client

Objective-C
2
star
16

APLLog

Logs debug output to console as alternative to NSLog
Objective-C
2
star
17

APLCoreDataStore

CoreData stack with synchronized NSManagedObjectContexts for main and private queue
Objective-C
2
star
18

ClientError

Log NSError or custom errors to the Parse.com database using the Parse iOS SDK and get error email reports
JavaScript
1
star
19

APLEasyTextField

Objective-C
1
star
20

APLStoryboardContainerViewController

A container view controller referencing and automatically loading view controller residing in different storyboards. The foreign view controller will be embedded as child view controller.
Objective-C
1
star
21

APLUIKitExtension

Useful UIKit Extension
Swift
1
star
22

APLWhatsappProxyActivity

A UIActivity to be able to share something via whatsapp
Objective-C
1
star
23

iOS-App-Foundation

A collection of extensions, helper methods and functions etc. made with Swift
Swift
1
star
24

APLPullToRefreshContainer

Objective-C
1
star
25

APLIntroView

APLIntroView uses a single ViewController to extend the launch screen by displaying a launch image or showing a video with configurable options.
Swift
1
star
26

APLArrayDataSource

UITableViewDataSource for NSArray
Objective-C
1
star
27

AdaptiveSidebarViewController

A simple container which can adaptively display an iOS viewcontroller in a sidebar
Swift
1
star
28

APLTableViewModel

A table view model which can be observed via delegate
Objective-C
1
star
29

APLUrlTextView

A simple UITextView extension allowing to add URLs and offering the possibility to be informed when such an URL has been selected by the user
Objective-C
1
star
30

APLProgressKringel

Objective-C
1
star