GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - solejay/MZSelectableLabel: A simple to use drop in replacement for UILabel for iOS 7 that provides automatic detection of colors.

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

2 Commits
2 Commits

Folders and files

NameName
Last commit message
Last commit date
MZSelectableLabel
MZSelectableLabel
 
 
MZSelectableLabelDemo
MZSelectableLabelDemo
 
 
Screens
Screens
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

MZSelectableLabel

A simple to use drop in replacement for UILabel for iOS 7 that provides automatic detection of colors.

How To Use

  1. Add the files MZSelectableLabel.m and MZSelectableLabel.h to your project.
  2. Design your user interface as you would normally. In Interface Builder set the custom class for any UILabel you want to replace to MZSelectableLabel. The label should honour all IB settings or create MZSelectableLabel objects in code.

Additional:

You can set automatic foreground color detection:

@property (nonatomic, assign, getter = isAutomaticForegroundColorDetectionEnabled) IBInspectable BOOL automaticForegroundColorDetectionEnabled;
@property (nonatomic, strong) IBInspectable UIColor *skipColorForAutomaticDetection;

This means that if you have attributed string, MZSelectableLabel will detect all ranges for you. Even you can skip detection for default color for example [UIColor blackColor].

Example

[self.label setSelectableRange:[[self.label.attributedText string] rangeOfString:@"Tap me"] hightlightedBackgroundColor:[UIColor colorWithWhite:0.3 alpha:0.3]];

self.label.selectionHandler = ^(NSRange range, NSString *string) {

    NSString *message = [NSString stringWithFormat:@"You tapped %@", string];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hello"
                                                    message:message
                                                   delegate:nil
                                          cancelButtonTitle:@"Dismiss"
                                          otherButtonTitles:nil];
    [alert show];
};

Demo

Repository includes MZSelectableLabel that shows a simple use of the label in a storyboard with examples for implementing tappable links.

The demo also demonstrates how to use a gesture recognizer with the label to implement a long press on a link, which uses the rangeValueAtLocation method.

Requirements

MZSelectableLabel requires either iOS 7.x and above.

Contact

Michal Zaborowski

Twitter

About

A simple to use drop in replacement for UILabel for iOS 7 that provides automatic detection of colors.

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.