RichModel.m 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // RichModel.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2020/1/11.
  6. // Copyright © 2020 tederen. All rights reserved.
  7. //
  8. #import "RichModel.h"
  9. #import "MMRichTextConfig.h"
  10. #import "MMRichContentUtil.h"
  11. @interface RichModel ()
  12. @property (nonatomic, strong) NSAttributedString* attrString;
  13. @end
  14. @implementation RichModel
  15. - (NSAttributedString*)attrStringWithContainer{
  16. if (!_attrString) {
  17. NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init];
  18. CGRect rect = CGRectZero;
  19. rect.size.width = SCREEN_WIDTH;
  20. rect.size.height = 128.f;
  21. textAttachment.bounds = rect;
  22. textAttachment.image = [UIImage new];
  23. NSAttributedString *attachmentString = [NSAttributedString attributedStringWithAttachment:textAttachment];
  24. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@""];
  25. [attributedString insertAttributedString:attachmentString atIndex:0];
  26. _attrString = attributedString;
  27. }
  28. return _attrString;
  29. }
  30. @end