2
0

UILabel+YBAttributeTextTapAction.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // UILabel+YBAttributeTextTapAction.h
  3. //
  4. // Created by LYB on 16/7/1.
  5. // Copyright © 2016年 LYB. All rights reserved.
  6. //
  7. #import <UIKit/UIKit.h>
  8. @protocol YBAttributeTapActionDelegate <NSObject>
  9. @optional
  10. /**
  11. * YBAttributeTapActionDelegate
  12. *
  13. * @param string 点击的字符串
  14. * @param range 点击的字符串range
  15. * @param index 点击的字符在数组中的index
  16. */
  17. - (void)yb_tapAttributeInLabel:(UILabel *)label
  18. string:(NSString *)string
  19. range:(NSRange)range
  20. index:(NSInteger)index;
  21. @end
  22. @interface UILabel (YBAttributeTextTapAction)
  23. /**
  24. * 是否打开点击效果,默认是打开
  25. */
  26. @property (nonatomic, assign) BOOL enabledTapEffect;
  27. /**
  28. * 点击高亮色 默认是[UIColor lightGrayColor] 需打开enabledTapEffect才有效
  29. */
  30. @property (nonatomic, strong) UIColor * tapHighlightedColor;
  31. /**
  32. * 是否扩大点击范围,默认是打开
  33. */
  34. @property (nonatomic, assign) BOOL enlargeTapArea;
  35. /**
  36. * 给文本添加点击事件Block回调
  37. *
  38. * @param strings 需要添加的字符串数组
  39. * @param tapClick 点击事件回调
  40. */
  41. - (void)yb_addAttributeTapActionWithStrings:(NSArray <NSString *> *)strings
  42. tapClicked:(void (^) (UILabel * label, NSString *string, NSRange range, NSInteger index))tapClick;
  43. /**
  44. * 给文本添加点击事件delegate回调
  45. *
  46. * @param strings 需要添加的字符串数组
  47. * @param delegate delegate
  48. */
  49. - (void)yb_addAttributeTapActionWithStrings:(NSArray <NSString *> *)strings
  50. delegate:(id <YBAttributeTapActionDelegate> )delegate;
  51. /**
  52. * 根据range给文本添加点击事件Block回调
  53. *
  54. * @param ranges 需要添加的Range字符串数组
  55. * @param tapClick 点击事件回调
  56. */
  57. - (void)yb_addAttributeTapActionWithRanges:(NSArray <NSString *> *)ranges
  58. tapClicked:(void (^) (UILabel * label, NSString *string, NSRange range, NSInteger index))tapClick;
  59. /**
  60. * 根据range给文本添加点击事件delegate回调
  61. *
  62. * @param ranges 需要添加的Range字符串数组
  63. * @param delegate delegate
  64. */
  65. - (void)yb_addAttributeTapActionWithRanges:(NSArray <NSString *> *)ranges
  66. delegate:(id <YBAttributeTapActionDelegate> )delegate;
  67. /**
  68. * 删除label上的点击事件
  69. */
  70. - (void)yb_removeAttributeTapActions;
  71. @end