LZBEmojiButton.m 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // LZBEmojiButton.m
  3. // LZBKeyBoardView
  4. //
  5. // demo地址:https://github.com/lzbgithubcode/LZBKeyBoardView.git
  6. // Created by zibin on 16/12/6.
  7. // Copyright © 2016年 apple. All rights reserved.
  8. //
  9. #import "LZBEmojiButton.h"
  10. #import "NSString+LZBTranscoding.h"
  11. #define LZBKeyboardBundleImage(name) [UIImage imageNamed:[NSString stringWithFormat:@"%@%@",@"Resource.bundle/",name]]
  12. @implementation LZBEmojiButton
  13. - (instancetype)initWithFrame:(CGRect)frame
  14. {
  15. if(self = [super initWithFrame:frame])
  16. {
  17. [self youpaifsetupUI];
  18. }
  19. return self;
  20. }
  21. - (void)youpaifsetupUI
  22. {
  23. self.adjustsImageWhenHighlighted = NO;
  24. self.titleLabel.font = [UIFont systemFontOfSize:32];
  25. }
  26. - (void)setModel:(LZBEmojiModel *)model
  27. {
  28. _model = model;
  29. if (model.png) { // 有图片
  30. [self setImage:LZBKeyboardBundleImage(model.png) forState:UIControlStateNormal];
  31. } else if (model.code) { // 是emoji表情
  32. // 设置emoji
  33. [self setTitle:model.code.emoji forState:UIControlStateNormal];
  34. }
  35. }
  36. @end