MOGuildImageOrTextBaseCell.m 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //
  2. // MOGuildImageOrTextBaseCell.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2023/10/26.
  6. //
  7. #import "MOGuildImageOrTextBaseCell.h"
  8. @implementation MOGuildImageOrTextBaseCell
  9. - (void)awakeFromNib {
  10. [super awakeFromNib];
  11. // Initialization code
  12. [self.contentView addSubview:self.contantBtn];
  13. [self.contantBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  14. make.right.equalTo(self.contentView).offset(-27.0);
  15. make.centerY.equalTo(self.contentView);
  16. make.top.equalTo(self.contentView).offset(5.0);
  17. make.bottom.equalTo(self.contentView).offset(-5.0);
  18. }];
  19. self.contantBtn.imageView.contentMode = UIViewContentModeScaleAspectFit;
  20. }
  21. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  22. [super setSelected:selected animated:animated];
  23. // Configure the view for the selected state
  24. }
  25. - (void)layoutSubviews{
  26. [super layoutSubviews];
  27. if(self.cellType == MOGuildOnlyTextCellType){
  28. //纯文本
  29. [self.contantBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
  30. [self.contantBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
  31. [self.contantBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  32. make.right.equalTo(self.contentView).offset(-27.0);
  33. make.centerY.equalTo(self.contentView);
  34. make.top.equalTo(self.contentView).offset(5.0);
  35. make.bottom.equalTo(self.contentView).offset(-5.0);
  36. }];
  37. self.contantBtn.layer.cornerRadius = 0.0;
  38. self.contantBtn.layer.borderColor = [UIColor whiteColor].CGColor;
  39. }
  40. else if (self.cellType == MOGuildCountryImageCellType){
  41. //国旗图片
  42. [self.contantBtn setTitle:@"" forState:UIControlStateNormal];
  43. [self.contantBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  44. make.right.equalTo(self.contentView).offset(-27.0);
  45. make.centerY.equalTo(self.contentView);
  46. make.width.height.equalTo(@24.0);
  47. }];
  48. self.contantBtn.layer.cornerRadius = 0.0;
  49. self.contantBtn.layer.borderColor = [UIColor whiteColor].CGColor;
  50. }
  51. else{
  52. //工会头像图片
  53. [self.contantBtn setTitle:@"" forState:UIControlStateNormal];
  54. [self.contantBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  55. make.right.equalTo(self.contentView).offset(-27.0);
  56. make.centerY.equalTo(self.contentView);
  57. make.width.height.equalTo(@24.0);
  58. }];
  59. self.contantBtn.layer.cornerRadius = 24.0 / 2.0;
  60. self.contantBtn.layer.masksToBounds = YES;
  61. self.contantBtn.layer.borderColor = [MOTools colorWithHexString:@"#E72DD3" alpha:1.0].CGColor;
  62. self.contantBtn.layer.borderWidth = 1.0;
  63. }
  64. }
  65. - (BigBtn *)contantBtn{
  66. if(!_contantBtn){
  67. _contantBtn = [BigBtn buttonWithType:UIButtonTypeCustom];
  68. [_contantBtn setTitleColor:[MOTools colorWithHexString:@"#120817" alpha:1.0] forState:UIControlStateNormal];
  69. _contantBtn.titleLabel.font = [UIFont systemFontOfSize:14.0];
  70. [_contantBtn setTitle:@"" forState:UIControlStateNormal];
  71. [_contantBtn addTarget:self action:@selector(contantBtnClick) forControlEvents:UIControlEventTouchUpInside];
  72. }
  73. return _contantBtn;
  74. }
  75. - (void)contantBtnClick{
  76. self.itemBtnClick ? self.itemBtnClick() : nil;
  77. }
  78. - (IBAction)cellBtnClick:(id)sender {
  79. self.itemBtnClick ? self.itemBtnClick() : nil;
  80. }
  81. @end