-
Notifications
You must be signed in to change notification settings - Fork 1
/
YMLabel.h
34 lines (25 loc) · 1.09 KB
/
YMLabel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
// YMLabel.h
// Demo
//
// Created by 张艳明 on 2018/7/5.
// Copyright © 2018年 张艳明. All rights reserved.
//
#import <UIKit/UIKit.h>
@protocol YMLabelDelegate <NSObject>
- (void)didSelectedOnLabel:(UILabel *)label selectedText:(NSString *)text range:(NSRange)range rangIndex:(NSInteger)index;
@end
// ⚠️ 现在默认必须设置sizeToFit 否则点击位置确定不准确
typedef void(^SelectedBlock)(UILabel *label, NSString *text, NSRange range, NSInteger index);
@interface YMLabel : UILabel
/** 正则表达式数组 匹配需要添加点击事件的文字 */
@property (nonatomic, copy) NSArray *regexStringArray;
/** 符合正则判断的文字颜色 */
@property (nonatomic, strong) UIColor *regexTextColor;
/** 点击符合正则判断的文字 显示的背景颜色 默认是空的 */
@property (nonatomic, strong) UIColor *regexBackgroundColor;
// 下面两个方式 可以二选一
@property (nonatomic, weak) id <YMLabelDelegate> delegate;
@property (nonatomic, copy) SelectedBlock block;
- (instancetype)initWithFrame:(CGRect)frame seletedBlock:(SelectedBlock)block;
@end