PracticeExamCell.m 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // PracticeExamCell.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2019/8/27.
  6. // Copyright © 2019 JCZ. All rights reserved.
  7. //
  8. #import "PracticeExamCell.h"
  9. #import "QuestionModel.h"
  10. @interface PracticeExamCell()
  11. @property(nonatomic,strong)UIImageView *imageV;
  12. @property(nonatomic,strong)UILabel *quesLab;
  13. @end
  14. @implementation PracticeExamCell
  15. + (instancetype)cellWithTableView:(UITableView *)tablView;
  16. {
  17. static NSString *ID = @"PracticeExamCell";
  18. PracticeExamCell *cell = [tablView dequeueReusableCellWithIdentifier:ID];
  19. if (cell == nil) {
  20. cell = [[PracticeExamCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
  21. }
  22. return cell;
  23. }
  24. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  25. {
  26. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  27. if (self) {
  28. [self creatUI];
  29. }
  30. return self;
  31. }
  32. -(void)creatUI{
  33. self.backgroundColor = [UIColor clearColor];
  34. [self.contentView addSubview:self.imageV];
  35. [self.contentView addSubview:self.quesLab];
  36. [_quesLab mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.top.mas_equalTo(20);
  38. make.left.mas_equalTo(50);
  39. make.right.bottom.mas_equalTo(-20);
  40. }];
  41. WeakSelf(weakSelf)
  42. [_imageV mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.left.mas_equalTo(15);
  44. make.centerY.equalTo(weakSelf.quesLab.mas_centerY);
  45. make.width.height.mas_equalTo(25);
  46. }];
  47. }
  48. -(UIImageView *)imageV{
  49. if (!_imageV) {
  50. _imageV = [[UIImageView alloc]init];
  51. }
  52. return _imageV;
  53. }
  54. -(UILabel *)quesLab{
  55. if (!_quesLab) {
  56. _quesLab = [UILabel new];
  57. _quesLab.numberOfLines = 0;
  58. }
  59. return _quesLab;
  60. }
  61. /// type 0对1错2默认3多选题点后后变色 . */
  62. - (void)setItem:(AnswerItem *)Item
  63. {
  64. _item = Item;
  65. //0对1错2默认3多选题点后后变色
  66. if (Item.type == 0) {
  67. self.quesLab.textColor = defGreen;
  68. }else if (Item.type == 1){
  69. self.quesLab.textColor = UIColor.redColor;
  70. }else if (Item.type == 2){//默认和多选取消选中结果后变色
  71. self.quesLab.textColor = defGreen;
  72. }else if (Item.type == 3){
  73. self.quesLab.textColor = defGreen;
  74. }
  75. self.imageV.image = [UIImage imageNamed:Item.picname];
  76. self.quesLab.text = Item.text;
  77. }
  78. @end