AccompanyRemarkCell.m 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // AccompanyRemarkCell.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by 王智 on 2022/4/6.
  6. //
  7. #import "AccompanyRemarkCell.h"
  8. @interface AccompanyRemarkCell ()
  9. @property (weak, nonatomic) IBOutlet UIView *emptyView;
  10. @property (weak, nonatomic) IBOutlet UILabel *contentLabel;
  11. @property (weak, nonatomic) IBOutlet UIView *remarkView;
  12. @property (nonatomic, copy) HomeworkRemarkCallback callback;
  13. @end
  14. @implementation AccompanyRemarkCell
  15. - (void)awakeFromNib {
  16. [super awakeFromNib];
  17. // Initialization code
  18. self.selectionStyle = UITableViewCellSelectionStyleNone;
  19. }
  20. - (void)configWithRemarkMessage:(NSString *)evaluateMessage hasEvaluate:(BOOL)hasEvaluate callback:(HomeworkRemarkCallback)callback {
  21. if (callback) {
  22. self.callback = callback;
  23. }
  24. if (hasEvaluate) {
  25. self.emptyView.hidden = YES;
  26. self.remarkView.hidden = YES;
  27. if (![NSString isEmptyString:evaluateMessage]) {
  28. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  29. [paragraphStyle setLineSpacing:4];//调整行间距
  30. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:evaluateMessage attributes:@{NSParagraphStyleAttributeName:paragraphStyle,NSFontAttributeName:[UIFont systemFontOfSize:13.0f],NSForegroundColorAttributeName:HexRGB(0x333333)}];
  31. self.contentLabel.attributedText = attr;
  32. }
  33. else {
  34. self.contentLabel.text = @"";
  35. }
  36. }
  37. else {
  38. self.emptyView.hidden = NO;
  39. self.remarkView.hidden = NO;
  40. self.contentLabel.text = @"";
  41. }
  42. }
  43. - (IBAction)remarkAction:(id)sender {
  44. if (self.callback) {
  45. self.callback();
  46. }
  47. }
  48. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  49. [super setSelected:selected animated:animated];
  50. // Configure the view for the selected state
  51. }
  52. @end