TUIInputMoreCell.m 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. [self addSubview:_title];
  27. }
  28. - (void)fillWithData:(TUIInputMoreCellData *)data {
  29. // set data
  30. _data = data;
  31. self.hidden = (data == nil) ? YES : NO;
  32. _image.image = data.image;
  33. [_title setText:data.title];
  34. // update layout
  35. CGSize menuSize = TMoreCell_Image_Size;
  36. _image.frame = CGRectMake(0, 0, menuSize.width, menuSize.height);
  37. _title.frame = CGRectMake(0, _image.frame.origin.y + _image.frame.size.height, _image.frame.size.width + 10, TMoreCell_Title_Height);
  38. _title.center = CGPointMake(_image.center.x, _title.center.y);
  39. }
  40. + (CGSize)getSize {
  41. CGSize menuSize = TMoreCell_Image_Size;
  42. return CGSizeMake(menuSize.width, menuSize.height + TMoreCell_Title_Height);
  43. }
  44. @end
  45. @interface IUChatView : UIView
  46. @property(nonatomic, strong) UIView *view;
  47. @end
  48. @implementation IUChatView
  49. - (instancetype)init {
  50. self = [super init];
  51. if (self) {
  52. self.view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)];
  53. [self addSubview:self.view];
  54. }
  55. return self;
  56. }
  57. @end