TUIMenuCell.m 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // InputMenuCell.m
  3. // UIKit
  4. //
  5. // Created by kennethmiao on 2018/9/20.
  6. // Copyright © 2018 Tencent. All rights reserved.
  7. //
  8. #import "TUIMenuCell.h"
  9. #import <TIMCommon/TIMDefine.h>
  10. #import <TUICore/TUIThemeManager.h>
  11. @implementation TUIMenuCell
  12. - (id)initWithFrame:(CGRect)frame {
  13. self = [super initWithFrame:frame];
  14. if (self) {
  15. [self setupViews];
  16. [self defaultLayout];
  17. }
  18. return self;
  19. }
  20. - (void)setupViews {
  21. self.backgroundColor = TUIChatDynamicColor(@"chat_controller_bg_color", @"#EBF0F6");
  22. _menu = [[UIImageView alloc] init];
  23. _menu.backgroundColor = [UIColor clearColor];
  24. [self addSubview:_menu];
  25. }
  26. - (void)defaultLayout {
  27. }
  28. - (void)setData:(TUIMenuCellData *)data {
  29. // set data
  30. _menu.image = [[TUIImageCache sharedInstance] getFaceFromCache:data.path];
  31. if (data.isSelected) {
  32. self.backgroundColor = TUIChatDynamicColor(@"chat_face_menu_select_color", @"#FFFFFF");
  33. } else {
  34. self.backgroundColor = TUIChatDynamicColor(@"chat_input_controller_bg_color", @"#EBF0F6");
  35. }
  36. // update layout
  37. CGSize size = self.frame.size;
  38. _menu.frame = CGRectMake(TMenuCell_Margin, TMenuCell_Margin, size.width - 2 * TMenuCell_Margin, size.height - 2 * TMenuCell_Margin);
  39. _menu.contentMode = UIViewContentModeScaleAspectFit;
  40. }
  41. @end