EmojiTextAttachment.m 852 B

12345678910111213141516171819202122232425262728293031323334
  1. //
  2. // EmojiTextAttachment.m
  3. // BuguLive
  4. //
  5. // Created by 朱庆彬 on 2017/8/15.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "EmojiTextAttachment.h"
  9. @implementation EmojiTextAttachment
  10. - (CGRect)attachmentBoundsForTextContainer:(NSTextContainer *)textContainer proposedLineFragment:(CGRect)lineFrag glyphPosition:(CGPoint)position characterIndex:(NSUInteger)charIndex
  11. {
  12. return CGRectMake(0, self.Top, lineFrag.size.height * self.Scale, lineFrag.size.height * self.Scale);
  13. }
  14. - (instancetype)initWithData:(NSData *)contentData ofType:(NSString *)uti
  15. {
  16. self = [super initWithData:contentData ofType:uti];
  17. if (self)
  18. {
  19. self.Scale = 1.0f;
  20. self.Top = 0.0f;
  21. if (self.image == nil)
  22. {
  23. self.image = [UIImage imageWithData:contentData];
  24. }
  25. }
  26. return self;
  27. }
  28. @end