Git Product home page Git Product logo

tccopyablelabel's Introduction

TCCopyableLabel

Provide the best UX to your users!

TCCopyableLabel is a subclass of UILabel that allows a user to copy the label's text to the clipboard, just like a regular text input. This can be really useful in some situations where you dispplay some important real-life informations.

Demo

Inspired from Mattt Thompson's article about copyable labels I read in his great NSHipster book.

  • Compatible with Interface Builder.
  • Custom string to be copied in the clipboard instead of the label's text (perform formatting to make your user's life easier).
  • Delegate and block on copy events.
  • Press to copy duration is customizable.

Documentation ๐Ÿ“š

Browse the documentation on Cocoadocs or add it directly to Xcode by downloading the docset and placing it into ~/Library/Developer/Shared/Documentation/DocSets/. (or use the great Dash)

Installation

Cocoapod

Add the following to your Podfile and run $ pod install:

pod 'TCCopyableLabel'

If you don't have CocoaPods installed or integrated into your project, you can learn how to do so here.

Static files

Copy/paste TCCopyableLabel/TCCopyableLabel/TCopyableLabel.{h,m} class in your project.

Import the class:

#import "TCCopyableLabel.h"

Examples

Instanciate it as you would do with a regular UILabel:

TCCopyableLabel *copyableLabel = [[TCCopyableLabel alloc] init];
[copyableLabel setText:@"Important stuff"];

// customization stuff
[copyableLabel setMinimumPressDuration:3];
[copyableLabel setCustomString:@"Custom string to be copied"];

If you are using Interface Builder, don't forget to add TCCopyableLabel in the class field:

Interface Builder Example

If you wish to perform something once a particular label has been copied, you can do so using the TCCopyableLabelDelegate or the copiedBlock property:

TCCopyableLabel *copiableLabel1 = [[TCCopyableLabel alloc] initWithFrame:frame delegate:self];

TCCopyableLabel *copyableLabel2 = [[TCCopyableLabel alloc] initWithFrame:frame  copiedBlock:^(NSString *copiedString) {
  // do stuff
}];

tccopyablelabel's People

Contributors

thibaultcha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.