HomeInformationCell.m 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // HomeInformationCell.m
  3. // KulexiuForStudent
  4. //
  5. // Created by 王智 on 2022/4/21.
  6. //
  7. #import "HomeInformationCell.h"
  8. @interface HomeInformationCell ()
  9. @property (weak, nonatomic) IBOutlet UILabel *messageTitle;
  10. @property (weak, nonatomic) IBOutlet UILabel *timeLabel;
  11. @property (weak, nonatomic) IBOutlet UIImageView *messageImage;
  12. @property (weak, nonatomic) IBOutlet UIView *backView;
  13. @end
  14. @implementation HomeInformationCell
  15. - (void)awakeFromNib {
  16. [super awakeFromNib];
  17. // Initialization code
  18. self.selectionStyle = UITableViewCellSelectionStyleNone;
  19. }
  20. - (void)configCellWithSource:(HomeMessageModel *)model rowIndex:(ROWINDEX)rowIndex {
  21. self.messageTitle.text = [NSString returnNoNullStringWithString:model.title];
  22. self.timeLabel.text = [model.createTime dateFormatString];
  23. [self.messageImage sd_setImageWithURL:[NSURL URLWithString:[model.coverImage getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:@"video_placeholder"]];
  24. if (rowIndex == ROWINDEX_TOP) {
  25. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, kScreenWidth - 28, 90) byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(10, 10)];
  26. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  27. maskLayer.frame = self.backView.bounds;
  28. maskLayer.path = maskPath.CGPath;
  29. self.backView.layer.mask = maskLayer;
  30. }
  31. else if (rowIndex == ROWINDEX_BOTTOM) {
  32. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, kScreenWidth - 28, 90) byRoundingCorners:UIRectCornerBottomLeft|UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];
  33. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  34. maskLayer.frame = self.backView.bounds;
  35. maskLayer.path = maskPath.CGPath;
  36. self.backView.layer.mask = maskLayer;
  37. }
  38. else if (rowIndex == ROWINDEX_TOP_BOTTOM) {
  39. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, kScreenWidth - 28, 90) byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight|UIRectCornerBottomLeft|UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];
  40. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  41. maskLayer.frame = self.backView.bounds;
  42. maskLayer.path = maskPath.CGPath;
  43. self.backView.layer.mask = maskLayer;
  44. }
  45. else {
  46. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, kScreenWidth - 28, 90) byRoundingCorners:UIRectCornerBottomLeft|UIRectCornerBottomRight cornerRadii:CGSizeMake(0, 0)];
  47. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  48. maskLayer.frame = self.backView.bounds;
  49. maskLayer.path = maskPath.CGPath;
  50. self.backView.layer.mask = maskLayer;
  51. }
  52. }
  53. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  54. [super setSelected:selected animated:animated];
  55. // Configure the view for the selected state
  56. }
  57. @end