|
| 1 | +/********************************************************************************** |
| 2 | + * |
| 3 | + * The MIT License (MIT) |
| 4 | + * |
| 5 | + * Copyright (c) 2014 Michał Zaborowski |
| 6 | + * |
| 7 | + * This project is an rewritten version of the KILabel |
| 8 | + * |
| 9 | + * https://github.com/Krelborn/KILabel |
| 10 | + *********************************************************************************** |
| 11 | + * |
| 12 | + * The MIT License (MIT) |
| 13 | + * |
| 14 | + * Copyright (c) 2013 Matthew Styles |
| 15 | + * |
| 16 | + * Permission is hereby granted, free of charge, to any person obtaining a copy of |
| 17 | + * this software and associated documentation files (the "Software"), to deal in |
| 18 | + * the Software without restriction, including without limitation the rights to |
| 19 | + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
| 20 | + * the Software, and to permit persons to whom the Software is furnished to do so, |
| 21 | + * subject to the following conditions: |
| 22 | + * |
| 23 | + * The above copyright notice and this permission notice shall be included in all |
| 24 | + * copies or substantial portions of the Software. |
| 25 | + * |
| 26 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 27 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
| 28 | + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
| 29 | + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| 30 | + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 31 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 32 | + * |
| 33 | + ***********************************************************************************/ |
| 34 | + |
| 35 | +#import <UIKit/UIKit.h> |
| 36 | + |
| 37 | +#ifndef IBInspectable |
| 38 | +#define IBInspectable |
| 39 | +#endif |
| 40 | + |
| 41 | +typedef void(^MZSelectableLabelTapHandler)(NSRange range, NSString *string); |
| 42 | + |
| 43 | +@interface MZSelectableLabelRange : NSObject |
| 44 | +@property (nonatomic, assign) NSRange range; |
| 45 | +@property (nonatomic, strong) UIColor *color; |
| 46 | + |
| 47 | ++ (instancetype)selectableRangeWithRange:(NSRange)range color:(UIColor *)color; |
| 48 | +@end |
| 49 | + |
| 50 | +@interface MZSelectableLabel : UILabel |
| 51 | +@property (nonatomic, copy) NSMutableArray *selectableRanges; |
| 52 | + |
| 53 | +//detected ranges in the text |
| 54 | +@property (nonatomic, copy) NSArray *detectedSelectableRanges; |
| 55 | + |
| 56 | +@property (nonatomic, copy) MZSelectableLabelTapHandler selectionHandler; |
| 57 | + |
| 58 | +@property (nonatomic, assign, getter = isAutomaticForegroundColorDetectionEnabled) IBInspectable BOOL automaticForegroundColorDetectionEnabled; |
| 59 | +@property (nonatomic, strong) IBInspectable UIColor *automaticDetectionBackgroundHighlightColor; |
| 60 | +@property (nonatomic, strong) IBInspectable UIColor *skipColorForAutomaticDetection; |
| 61 | + |
| 62 | +- (void)setSelectableRange:(NSRange)range; |
| 63 | +- (void)setSelectableRange:(NSRange)range hightlightedBackgroundColor:(UIColor *)color; |
| 64 | + |
| 65 | +- (MZSelectableLabelRange *)rangeValueAtLocation:(CGPoint)location; |
| 66 | + |
| 67 | +@end |
0 commit comments