YOUPAINIMInputEmoticonButton.m 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // YOUPAINIMInputEmoticonButton.m
  3. // NIMKit
  4. //
  5. // Created by chris.
  6. // Copyright (c) 2015年 NetEase. All rights reserved.
  7. //
  8. #import "YOUPAINIMInputEmoticonButton.h"
  9. #import "UIImage+NIMKit.h"
  10. #import "YOUPAINIMInputEmoticonManager.h"
  11. @implementation YOUPAINIMInputEmoticonButton
  12. + (YOUPAINIMInputEmoticonButton*)youpaificonButtonWithData:(NIMInputEmoticon*)data catalogID:(NSString*)catalogID delegate:( id<NIMEmoticonButtonTouchDelegate>)delegate{
  13. YOUPAINIMInputEmoticonButton* icon = [[YOUPAINIMInputEmoticonButton alloc] init];
  14. [icon addTarget:icon action:@selector(youpaifonIconSelected:) forControlEvents:UIControlEventTouchUpInside];
  15. UIImage *image = [UIImage nim_fetchEmoticon:data.filename];
  16. icon.emoticonData = data;
  17. icon.catalogID = catalogID;
  18. icon.userInteractionEnabled = YES;
  19. icon.exclusiveTouch = YES;
  20. icon.contentMode = UIViewContentModeScaleToFill;
  21. icon.delegate = delegate;
  22. [icon setImage:image forState:UIControlStateNormal];
  23. [icon setImage:image forState:UIControlStateHighlighted];
  24. return icon;
  25. }
  26. - (void)youpaifonIconSelected:(id)sender
  27. {
  28. if ([self.delegate respondsToSelector:@selector(selectedEmoticon:catalogID:)])
  29. {
  30. [self.delegate selectedEmoticon:self.emoticonData catalogID:self.catalogID];
  31. }
  32. }
  33. @end