MOGuildNewInputCell.m 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // MOGuildNewInputCell.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2025/3/16.
  6. //
  7. #import "MOGuildNewInputCell.h"
  8. @interface MOGuildNewInputCell ()<UITextFieldDelegate>
  9. @end
  10. @implementation MOGuildNewInputCell
  11. - (void)awakeFromNib {
  12. [super awakeFromNib];
  13. // Initialization code
  14. //Cell 去除选中效果
  15. self.selectionStyle = UITableViewCellSelectionStyleNone;
  16. self.backgroundColor = [UIColor clearColor];
  17. self.redTipView.layer.cornerRadius = 4.0;
  18. self.redTipView.layer.masksToBounds = YES;
  19. self.redTipView.backgroundColor = [MOTools colorWithHexString:@"#F23051" alpha:1.0];
  20. self.inputTxf.delegate = self;
  21. self.inputTxf.placeholder = @"Please enter";
  22. self.titleLab.font = [MOTextTools poppinsMediumFont:14.0];
  23. self.inputTxf.font = [MOTextTools poppinsLightFont:14.0];
  24. self.inputTxf.layer.cornerRadius = 8.0;
  25. self.inputTxf.layer.masksToBounds = YES;
  26. self.titleLab.textColor = kBaseTextColor_2;
  27. self.inputTxf.textColor = kBaseTextColor_2;
  28. UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 12.0, 36.0)];
  29. self.inputTxf.leftView = paddingView;
  30. self.inputTxf.leftViewMode = UITextFieldViewModeAlways;
  31. }
  32. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  33. [super setSelected:selected animated:animated];
  34. // Configure the view for the selected state
  35. }
  36. - (void)textFieldDidEndEditing:(UITextField *)textField
  37. {
  38. if (self.returnTxFText)
  39. {
  40. self.returnTxFText(textField.text);
  41. }
  42. }
  43. - (void)toCheckHaveRedTip{
  44. // 创建属性字符串,整体颜色为白色
  45. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:self.titleLab.text attributes:@{NSForegroundColorAttributeName:[MOTools colorWithHexString:@"#737373" alpha:1.0]}];
  46. NSRange redRange = [self.titleLab.text rangeOfString:@"*"];
  47. if(redRange.location != NSNotFound){
  48. // 将最后三个字符的颜色设置为红色
  49. [attributedString addAttribute:NSForegroundColorAttributeName value:[MOTools colorWithHexString:@"#FB5374" alpha:1.0] range:redRange];
  50. }
  51. self.titleLab.attributedText = attributedString;
  52. }
  53. - (void)setIsHaveRedTip:(BOOL)isHaveRedTip{
  54. _isHaveRedTip = isHaveRedTip;
  55. self.redTipView.hidden = !isHaveRedTip;
  56. if(isHaveRedTip){
  57. self.titleLabLeading.constant = 28.0;
  58. }
  59. else{
  60. self.titleLabLeading.constant = 16.0;
  61. }
  62. }
  63. @end