MOGlobalView.m 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // MOGlobalView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2025/9/8.
  6. //
  7. #import "MOGlobalView.h"
  8. @interface MOGlobalView ()
  9. @property (nonatomic, strong) UIImageView *iconImgView;
  10. @property (nonatomic, strong) UILabel *titleLab;
  11. @property (nonatomic, strong) UIButton *actionBtn;
  12. @end
  13. @implementation MOGlobalView
  14. - (instancetype)init {
  15. if (self = [super init] ) {
  16. [self setupUI];
  17. }
  18. return self;
  19. }
  20. - (instancetype)initWithFrame:(CGRect)frame{
  21. self = [super initWithFrame:frame];
  22. if (self){
  23. [self setupUI];
  24. }
  25. return self;
  26. }
  27. - (void)setupUI{
  28. [self addSubview:self.iconImgView];
  29. [self.iconImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.width.height.mas_equalTo(24.0);
  31. make.left.equalTo(self).offset(16.0);
  32. make.centerY.equalTo(self);
  33. }];
  34. [self addSubview:self.titleLab];
  35. [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.equalTo(self.iconImgView.mas_right).offset(12.0);
  37. make.centerY.equalTo(self);
  38. }];
  39. [self addSubview:self.actionBtn];
  40. [self.actionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.edges.equalTo(self);
  42. }];
  43. }
  44. #pragma mark - Lazy
  45. - (UILabel *)titleLab{
  46. if(!_titleLab)
  47. {
  48. _titleLab = [UILabel new];
  49. _titleLab.textColor = [MOTools colorWithHexString:@"#000000" alpha:1.0];
  50. _titleLab.textAlignment = NSTextAlignmentLeft;
  51. _titleLab.font = [MOTextTools poppinsRegularFont:16.0];
  52. _titleLab.backgroundColor = [UIColor clearColor];
  53. _titleLab.text = NSLocalString(@"mimo_country_global");
  54. }
  55. return _titleLab;
  56. }
  57. - (UIButton *)actionBtn{
  58. if(!_actionBtn){
  59. _actionBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  60. [_actionBtn setTitle:@"" forState:UIControlStateNormal];
  61. [_actionBtn addTarget:self action:@selector(actionBtnClickAction) forControlEvents:UIControlEventTouchUpInside];
  62. }
  63. return _actionBtn;
  64. }
  65. - (void)actionBtnClickAction{
  66. self.viewClickBlock ? self.viewClickBlock() : nil;
  67. }
  68. - (UIImageView *)iconImgView{
  69. if(!_iconImgView){
  70. _iconImgView = [[UIImageView alloc] init];
  71. _iconImgView.contentMode = UIViewContentModeScaleAspectFit;
  72. [_iconImgView setImage:[UIImage imageNamed:@"icon_global_48"]];
  73. }
  74. return _iconImgView;
  75. }
  76. @end