TUIInputMoreCell.m 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //
  2. // TMoreCell.m
  3. // UIKit
  4. //
  5. // Created by annidyfeng on 2019/5/22.
  6. // Copyright © 2023 Tencent. All rights reserved.
  7. //
  8. #import "TUIInputMoreCell.h"
  9. #import <TIMCommon/TIMDefine.h>
  10. @implementation TUIInputMoreCell
  11. - (id)initWithFrame:(CGRect)frame {
  12. self = [super initWithFrame:frame];
  13. if (self) {
  14. [self setupViews];
  15. }
  16. return self;
  17. }
  18. - (void)setupViews {
  19. _image = [[UIImageView alloc] init];
  20. _image.contentMode = UIViewContentModeScaleAspectFit;
  21. [self addSubview:_image];
  22. _title = [[UILabel alloc] init];
  23. [_title setFont:[UIFont systemFontOfSize:10]];
  24. [_title setTextColor:[UIColor grayColor]];
  25. _title.textAlignment = NSTextAlignmentCenter;
  26. _title.hidden = YES;
  27. [self addSubview:_title];
  28. }
  29. - (void)fillWithData:(TUIInputMoreCellData *)data {
  30. // set data
  31. _data = data;
  32. self.hidden = (data == nil) ? YES : NO;
  33. _image.image = data.image;
  34. [_title setText:data.title];
  35. // update layout
  36. CGSize menuSize = TMoreCell_Image_Size;
  37. menuSize = CGSizeMake(30, 30);
  38. _image.frame = CGRectMake(0, 0, menuSize.width, menuSize.height);
  39. _image.center = CGPointMake(20, 20);
  40. _title.frame = CGRectMake(0, _image.frame.origin.y + _image.frame.size.height, _image.frame.size.width + 10, TMoreCell_Title_Height);
  41. _title.center = CGPointMake(_image.center.x, _title.center.y);
  42. }
  43. + (CGSize)getSize {
  44. CGSize menuSize = TMoreCell_Image_Size;
  45. menuSize = CGSizeMake(40, 40);
  46. // return CGSizeMake(menuSize.width, menuSize.height + TMoreCell_Title_Height);
  47. return CGSizeMake(menuSize.width, menuSize.height);
  48. }
  49. @end
  50. @interface IUChatView : UIView
  51. @property(nonatomic, strong) UIView *view;
  52. @end
  53. @implementation IUChatView
  54. - (instancetype)init {
  55. self = [super init];
  56. if (self) {
  57. self.view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)];
  58. [self addSubview:self.view];
  59. }
  60. return self;
  61. }
  62. @end