GithubHelp home page GithubHelp logo

lsb332 / a-clickablelabel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from animaxx/a-clickablelabel

0.0 2.0 0.0 198 KB

A clickable and replaceable label

License: MIT License

Objective-C 100.00%

a-clickablelabel's Introduction

A-ClickableLabel

A clickable and replaceable label, you can define touch event for each character.

Demo

demo gif

Classes

A_AttributedStringBuilder is for generating custom style for your label; it can apply to either the whole sentence or a clickable element.

A_ClickableElement representing a clickable and replaceable element in the label.

A_ClickedAdditionalInformation included all infomration about the click event: clicked point, baseline point, clicked at which character, clicked at which line ,and current word.

A_ClickableLabel derived from UILabel for handle clickable and replaceable events.

Usage

[self.demoLabel setSentence:@"Hello %@." // set the sentence as "Hello world"

				// set style for whole sentence
                withBuilder:[[A_AttributedStringBuilder createWithSystemFontSize:14] setUnderline:YES]

                 // the "world" is the clickable element in this label
                 andElement:[A_ClickableElement create:@"world"

                 						   // set the style for this element
                                           withBuilder:[[A_AttributedStringBuilder createWithSystemFontSize:18] setUnderlineColor:[UIColor redColor]]
                                              andClick:^(A_ClickableElement *element, A_ClickableLabel *sender, A_ClickedAdditionalInformation *info) {
                                                  
                                                  // when user click on the element, update the style
                                                  [element.styleBuilder setUnderlineColor:[UIColor greenColor]];
                                                  
                                              }], nil
 ];

a-clickablelabel's People

Contributors

animaxx avatar

Watchers

James Cloos avatar Bin 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.