MessageFansCell.m 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //
  2. // MessageFansCell.m
  3. // YBVideo
  4. //
  5. // Created by YunBao on 2018/7/24.
  6. // Copyright © 2018年 cat. All rights reserved.
  7. //
  8. #import "MessageFansCell.h"
  9. @implementation MessageFansCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. _iconBtn.layer.masksToBounds = YES;
  13. _iconBtn.layer.cornerRadius = _iconBtn.width/2;
  14. _iconBtn.userInteractionEnabled = NO;//启用点击事件更改YES
  15. [_iconBtn.imageView setContentMode:UIViewContentModeScaleAspectFill];
  16. _iconBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
  17. _iconBtn.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
  18. _followBtn.layer.masksToBounds = YES;
  19. _followBtn.layer.cornerRadius = 13;
  20. _followBtn.layer.borderWidth = 1;
  21. }
  22. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  23. [super setSelected:selected animated:animated];
  24. }
  25. +(MessageFansCell*)cellWithTab:(UITableView *)tableView andIndexPath:(NSIndexPath*)indexPath {
  26. MessageFansCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MessageFansCell"];
  27. if (!cell) {
  28. cell = [[[NSBundle mainBundle]loadNibNamed:@"MessageFansCell" owner:nil options:nil]objectAtIndex:0];
  29. }
  30. return cell;
  31. }
  32. -(void)setModel:(MessageFansModel *)model {
  33. _model = model;
  34. [_iconBtn sd_setImageWithURL:[NSURL URLWithString:_model.iconStr] forState:0];
  35. _contentL.text = [NSString stringWithFormat:@"%@ %@",_model.unameStr,YZMsg(@"关注了你")];
  36. NSMutableAttributedString *attStr=[[NSMutableAttributedString alloc]initWithString:_contentL.text];
  37. [attStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0, _model.unameStr.length)];
  38. _contentL.attributedText = attStr;
  39. _timeL.text = _model.timeStr;
  40. if ([_model.isAttentStr isEqual:@"0"]) {
  41. _followBtn.layer.borderColor = Pink_Cor.CGColor;
  42. [_followBtn setTitle:YZMsg(@"关注") forState:0];
  43. [_followBtn setTitleColor:Pink_Cor forState:0];
  44. }else{
  45. _followBtn.layer.borderColor = RGB_COLOR(@"#4A4A52", 1).CGColor;
  46. [_followBtn setTitleColor:RGB_COLOR(@"#4A4A52", 1) forState:0];
  47. [_followBtn setTitle:YZMsg(@"已关注") forState:0];
  48. }
  49. }
  50. - (IBAction)clickIconBtn:(UIButton *)sender {
  51. //预留-awakeFromNib更改userInteractionEnabled属性
  52. }
  53. - (IBAction)clickFollowBtn:(UIButton *)sender {
  54. if ([[Config getOwnID] intValue]<=0) {
  55. [PublicObj warnLogin];
  56. return;
  57. }
  58. if ([[Config getOwnID] isEqual:_model.uidStr]) {
  59. [MBProgressHUD showError:YZMsg(@"不能关注自己")];
  60. return;
  61. }
  62. NSString *url = [NSString stringWithFormat:@"User.setAttent&uid=%@&touid=%@&token=%@",[Config getOwnID],_model.uidStr,[Config getOwnToken]];
  63. [YBNetworking postWithUrl:url Dic:nil Suc:^(int code, id info, NSString *msg) {
  64. if (code == 0) {
  65. NSString *infoDic = [info firstObject];
  66. NSString *isattent = [NSString stringWithFormat:@"%@",[infoDic valueForKey:@"isattent"]];
  67. if ([isattent isEqual:@"0"]) {
  68. _followBtn.layer.borderColor = Pink_Cor.CGColor;
  69. [_followBtn setTitle:YZMsg(@"关注") forState:0];
  70. [_followBtn setTitleColor:Pink_Cor forState:0];
  71. }else{
  72. _followBtn.layer.borderColor = RGB_COLOR(@"#4A4A52", 1).CGColor;
  73. [_followBtn setTitleColor:RGB_COLOR(@"#4A4A52", 1) forState:0];
  74. [_followBtn setTitle:YZMsg(@"已关注") forState:0];
  75. }
  76. }else{
  77. [MBProgressHUD showPop:msg];
  78. }
  79. } Fail:^(id fail) {
  80. }];
  81. }
  82. @end