ChatImageBubble.m 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // ChatImageBubble.m
  3. // ChatImageBubbleDemo
  4. //
  5. // Created by HuminiOS on 15/10/28.
  6. // Copyright © 2015年 HuminiOS. All rights reserved.
  7. //
  8. #import "ChatImageBubble.h"
  9. @implementation ChatImageBubble
  10. - (id)init {
  11. self = [super init];
  12. if (self != nil) {
  13. if (self.maskBubbleLayer == nil) {
  14. self.maskBubbleLayer = [ChatBubbleLayer layer];
  15. }
  16. // self.layer.mask = self.maskBubbleLayer;
  17. }
  18. return self;
  19. }
  20. - (void)setBubbleSide:(BOOL)isReci {
  21. self.maskBubbleLayer.isReceivedBubble = isReci;
  22. _isReceivedBubble = isReci;
  23. }
  24. - (void)setFrame:(CGRect)frame {
  25. [super setFrame:frame];
  26. // self.maskBubbleLayer.bounds = CGRectMake(0, 0, frame.size.width, frame.size.height);
  27. // self.maskBubbleLayer.frame = self.bounds;
  28. // [CATransaction begin];
  29. // self.maskBubbleLayer.duration = 0; // CALayer 的隐式动画的duration 为0.25秒, 可以通过事务在主动修改
  30. // [self.maskBubbleLayer setNeedsDisplay];
  31. // [CATransaction commit];
  32. // UIImageView *maskView = nil;
  33. // UIImage *maskImage = nil;
  34. // if (_isReceivedBubble) {
  35. // maskImage = [UIImage imageNamed:@"chat_bg_other"];
  36. // } else {
  37. // maskImage = [UIImage imageNamed:@"chat_bg_my"];
  38. // }
  39. // maskImage = [maskImage resizableImageWithCapInsets:UIEdgeInsetsMake(28, 20, 28, 20)];
  40. //
  41. //// maskView = [[UIImageView alloc] initWithImage:maskImage];
  42. // maskView = [UIImageView new];
  43. // maskView.image = maskImage;
  44. // [maskView setFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
  45. // self.layer.mask = maskView.layer;
  46. }
  47. @end