MatchParser.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // MatchParser.h
  3. // CoreTextMagazine
  4. //
  5. // Created by weqia on 13-10-27.
  6. // Copyright (c) 2013年 Marin Todorov. All rights reserved.
  7. //
  8. #import <CoreText/CoreText.h>
  9. #import <Foundation/Foundation.h>
  10. #define BEGIN_TAG @"["
  11. #define END_TAG @"]"
  12. #define MatchParserString @"string"
  13. #define MatchParserRange @"range"
  14. #define MatchParserRects @"rects"
  15. #define MatchParserImage @"image"
  16. #define MatchParserLocation @"location"
  17. #define MatchParserLine @"line"
  18. #define MatchParserLinkType @"lineType"
  19. #define MatchParserLinkTypeUrl @"MatchParserLinkTypeUrl"
  20. #define MatchParserLinkTypePhone @"MatchParserLinkTypePhone"
  21. #define MatchParserLinkTypeMobie @"MatchParserLinkTypeMobie"
  22. @class MatchParser;
  23. @protocol MatchParserDelegate <NSObject>
  24. @property(nonatomic,weak,getter = getMatch,setter = setMatch:) MatchParser * match;
  25. -(void)updateMatch:(void(^)(NSMutableAttributedString * string, NSRange range))link;
  26. -(MatchParser*)createMatch:(float)width;
  27. @optional
  28. -(void)setMatch;
  29. -(void)setMatch:(MatchParser *)match;
  30. -(MatchParser*)getMatch;
  31. -(MatchParser*)getMatch:(void(^)(MatchParser *parser,id data))complete data:(id)data;
  32. @end
  33. @interface MatchParser : NSObject
  34. {
  35. NSMutableArray * _strs;
  36. NSString * _source;
  37. float _height;
  38. id _ctFrame;
  39. float _miniWidth;
  40. int _numberOfTotalLines;
  41. float _heightOflimit;
  42. }
  43. @property(nonatomic,strong) NSMutableAttributedString * attrString;
  44. @property(nonatomic,strong) NSArray * images;
  45. @property(nonatomic,readonly) NSMutableArray * links;
  46. @property(nonatomic,strong) UIFont * font;
  47. @property(nonatomic,strong) UIColor * textColor;
  48. @property(nonatomic,strong) UIColor * keyWorkColor;
  49. @property(nonatomic) float line; //行距
  50. @property(nonatomic) float paragraph; // 段落间距
  51. @property(nonatomic) float MutiHeight; //多行行高
  52. @property(nonatomic) float fristlineindent; // 首行缩进
  53. @property(nonatomic) float iconSize; // 表情Size
  54. @property(nonatomic) float width; // 宽度
  55. @property(nonatomic) int numberOfLimitLines; // 行数限定 (等于0 代表 行数不限)
  56. @property(nonatomic) BOOL phoneLink;
  57. @property(nonatomic) BOOL mobieLink;
  58. @property(nonatomic) BOOL urlLink;
  59. @property(nonatomic,readonly) id ctFrame;
  60. @property(nonatomic)float height; // 总内容的高度
  61. @property(nonatomic,readonly)float heightOflimit; // 限定行数后的内容高度
  62. @property(nonatomic,readonly)float miniWidth; //只有一行时,内容宽度
  63. @property(nonatomic,readonly)int numberOfTotalLines; //内容行数
  64. @property(nonatomic,readonly) NSString * source; //原始内容
  65. @property(nonatomic,weak) id<MatchParserDelegate> data;
  66. -(void)match:(NSString*)text;
  67. -(void)match:(NSString*)text atCallBack:(BOOL(^)(NSString*))atString;
  68. -(void)match:(NSString *)source atCallBack:(BOOL (^)(NSString *))atString title:(NSAttributedString*)title;
  69. -(void)match:(NSString *)source atCallBack:(BOOL (^)(NSString *))atString title:(NSAttributedString *)title link:(void(^)(NSMutableAttributedString*attrString,NSRange range))link;
  70. @end