No Description

KXEventCollectionViewCell.m 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //
  2. // KXEventCollectionViewCell.m
  3. // CAISHEN
  4. //
  5. // Created by jikaipeng on 2017/8/25.
  6. // Copyright © 2017年 kuxuan. All rights reserved.
  7. //
  8. #import "KXEventCollectionViewCell.h"
  9. @interface KXEventCollectionViewCell ()
  10. @property (nonatomic, strong) UILabel *titlelabel;
  11. @property (nonatomic, strong) UIImageView *ImageView;
  12. @property (nonatomic, strong) UILabel *timeLabel;
  13. @property (nonatomic, strong) UILabel *detailLabel;
  14. @property (nonatomic, strong) UIImageView *backImageView;
  15. @end
  16. @implementation KXEventCollectionViewCell
  17. - (instancetype)initWithFrame:(CGRect)frame{
  18. if (self = [super initWithFrame:frame]) {
  19. [self addSubview:self.titlelabel];
  20. [self addSubview:self.ImageView];
  21. [self addSubview:self.timeLabel];
  22. [self addSubview:self.backImageView];
  23. [self addSubview:self.detailLabel];
  24. [self addConstaints];
  25. }
  26. return self;
  27. }
  28. #pragma mark - event handle
  29. - (void)addConstaints{
  30. [self.titlelabel mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.top.equalTo(self.mas_top).offset(16);
  32. make.left.equalTo(self.mas_left).offset(7);
  33. }];
  34. [self.ImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.size.equalTo(CGSizeMake(340*SCREEN_MUTI, 150*SCREEN_MUTI));
  36. make.left.equalTo(self.mas_left).offset(8);
  37. make.top.equalTo(self.titlelabel.mas_bottom).offset(8);
  38. }];
  39. [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.left.equalTo(self.ImageView.mas_left);
  41. make.top.equalTo(self.ImageView.mas_bottom).offset(8);
  42. }];
  43. [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.top.equalTo(self.timeLabel.mas_top);
  45. make.right.equalTo(self.ImageView.mas_right);
  46. make.size.equalTo(CGSizeMake(10, 13));
  47. }];
  48. [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.right.equalTo(self.backImageView.mas_left).offset(-20);
  50. make.top.equalTo(self.backImageView.mas_top);
  51. }];
  52. }
  53. #pragma mark - getter and setter
  54. - (void)setModel:(KXEventModel *)model{
  55. _model = model;
  56. self.titlelabel.text = model.title;
  57. [self.ImageView sd_setImageWithURL:[NSURL URLWithString:model.image_url] placeholderImage:[UIImage imageNamed:@"placeholder_rectangle"]];
  58. self.timeLabel.text = model.start_time;
  59. self.backImageView.image = [UIImage imageNamed:@"main_event_back"];
  60. self.detailLabel.text = @"查看详情";
  61. }
  62. - (UILabel *)timeLabel{
  63. if (!_timeLabel) {
  64. _timeLabel = [[UILabel alloc] init];
  65. _timeLabel.font = FONT_SYS(12);
  66. _timeLabel.textColor = [UIColor KXColorWithHex:0x666666];
  67. }
  68. return _timeLabel;
  69. }
  70. - (UILabel *)titlelabel{
  71. if (!_titlelabel) {
  72. _titlelabel = [[UILabel alloc] init];
  73. _titlelabel.font = FONT_SYS(16);
  74. _titlelabel.textColor = [UIColor titleColor];
  75. }
  76. return _titlelabel;
  77. }
  78. - (UILabel *)detailLabel{
  79. if (!_detailLabel) {
  80. _detailLabel = [[UILabel alloc] init];
  81. _detailLabel.font = FONT_SYS(12);
  82. _detailLabel.textColor = [UIColor KXColorWithHex:0x666666];
  83. }
  84. return _detailLabel;
  85. }
  86. - (UIImageView *)ImageView{
  87. if (!_ImageView) {
  88. _ImageView = [[UIImageView alloc] init];
  89. }
  90. return _ImageView;
  91. }
  92. - (UIImageView *)backImageView{
  93. if (!_backImageView) {
  94. _backImageView = [[UIImageView alloc] init];
  95. }
  96. return _backImageView;
  97. }
  98. @end