M80AttributedLabel.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // M80AttributedLabel.h
  3. // M80AttributedLabel
  4. //
  5. // Created by amao on 13-9-1.
  6. // Copyright (c) 2013年 www.xiangwangfeng.com. All rights reserved.
  7. //
  8. #import "M80AttributedLabelDefines.h"
  9. #import "NSMutableAttributedString+M80.h"
  10. NS_ASSUME_NONNULL_BEGIN
  11. @class M80AttributedLabelURL;
  12. @interface M80AttributedLabel : UIView
  13. @property (nonatomic,weak,nullable) id<M80AttributedLabelDelegate> delegate;
  14. @property (nonatomic,strong,nullable) UIFont *font; //字体
  15. @property (nonatomic,strong,nullable) UIColor *textColor; //文字颜色
  16. @property (nonatomic,strong,nullable) UIColor *highlightColor; //链接点击时背景高亮色
  17. @property (nonatomic,strong,nullable) UIColor *linkColor; //链接色
  18. @property (nonatomic,strong,nullable) UIColor *shadowColor; //阴影颜色
  19. @property (nonatomic,assign) CGSize shadowOffset; //阴影offset
  20. @property (nonatomic,assign) CGFloat shadowBlur; //阴影半径
  21. @property (nonatomic,assign) BOOL underLineForLink; //链接是否带下划线
  22. @property (nonatomic,assign) BOOL autoDetectLinks; //自动检测
  23. @property (nonatomic,assign) NSInteger numberOfLines; //行数
  24. @property (nonatomic,assign) CTTextAlignment textAlignment; //文字排版样式
  25. @property (nonatomic,assign) CTLineBreakMode lineBreakMode; //LineBreakMode
  26. @property (nonatomic,assign) CGFloat lineSpacing; //行间距
  27. @property (nonatomic,assign) CGFloat paragraphSpacing; //段间距
  28. @property (nonatomic,copy,nullable) NSString *text; //普通文本
  29. @property (nonatomic,copy,nullable) NSAttributedString *attributedText; //属性文本
  30. //添加文本
  31. - (void)appendText:(NSString *)text;
  32. - (void)appendAttributedText:(NSAttributedString *)attributedText;
  33. //图片
  34. - (void)appendImage:(UIImage *)image;
  35. - (void)appendImage:(UIImage *)image
  36. maxSize:(CGSize)maxSize;
  37. - (void)appendImage:(UIImage *)image
  38. maxSize:(CGSize)maxSize
  39. margin:(UIEdgeInsets)margin;
  40. - (void)appendImage:(UIImage *)image
  41. maxSize:(CGSize)maxSize
  42. margin:(UIEdgeInsets)margin
  43. alignment:(M80ImageAlignment)alignment;
  44. //UI控件
  45. - (void)appendView:(UIView *)view;
  46. - (void)appendView:(UIView *)view
  47. margin:(UIEdgeInsets)margin;
  48. - (void)appendView:(UIView *)view
  49. margin:(UIEdgeInsets)margin
  50. alignment:(M80ImageAlignment)alignment;
  51. //添加自定义链接
  52. - (void)addCustomLink:(id)linkData
  53. forRange:(NSRange)range;
  54. - (void)addCustomLink:(id)linkData
  55. forRange:(NSRange)range
  56. linkColor:(UIColor *)color;
  57. //大小
  58. - (CGSize)sizeThatFits:(CGSize)size;
  59. //设置全局的自定义Link检测Block(详见M80AttributedLabelURL)
  60. + (void)setCustomDetectMethod:(nullable M80CustomDetectLinkBlock)block;
  61. @end
  62. NS_ASSUME_NONNULL_END