Skip to content
A token field implementation for iOS
Swift Ruby
Branch: master
Clone or download
Latest commit 75e168a Jul 9, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example Added shared scheme. Jul 9, 2019
ResizingTokenField Using intrinsic content height instead of height constraint. Jul 2, 2019
.gitignore Initial commit Jul 1, 2019
.travis.yml Travis build destination Jul 3, 2019
LICENSE Initial commit Jul 1, 2019 Updated readme Jul 9, 2019
ResizingTokenField.podspec Updated podspec Jul 9, 2019
_Pods.xcodeproj Initial commit Jul 1, 2019


Build Status Version License Platform

A token field implementation written in Swift 5.

Example GIF


  • Can be used in Interface Builder or created programmatically
  • Uses a UICollectionView to display tokens, allowing token changes to be animated
  • Automatically updates intrinsic height as content is added and removed
  • Supports collapsing tokens into a text description
  • Allows providing a custom UICollectionViewCell for tokens



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

pod 'ResizingTokenField', '~> 0.1.1'


To install via Carthage, add the following to your Cartfile:

github "tadejr/ResizingTokenField" "0.1.1"


The token field can be used via Interface Builder - add an empty UIView to your layout and set its class to ResizingTokenField. It can also be initialized programmatically by using init(frame:).

Meant to be used with auto layout; it provides intrinsic content height, meaning you only need to pin its position and width, height will change automatically as content is added and removed from the field. In Interface Builder, the Placeholder Intrinsic Size setting can be used for height.


Customization is possible by setting appropriate properties on a ResizingTokenField instance. Additionally, three different delegates can be set to handle specific behaviour. Check the example project for more info.

Rotation support

The token field does not automatically invalidate layout when its bounds change. To handle device rotation you should manually invalidate layout.

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransition(to: size, with: coordinator)

Height change animation

To animate changes to the token field's height you should call layoutIfNeeded() on an appropriate superview when token field intrinsic height changes.

func resizingTokenField(_ tokenField: ResizingTokenField, willChangeIntrinsicHeight newHeight: CGFloat) {

func resizingTokenField(_ tokenField: ResizingTokenField, didChangeIntrinsicHeight newHeight: CGFloat) {
    UIView.animate(withDuration: tokenField.animationDuration) {


Tadej Razborsek,


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

You can’t perform that action at this time.