| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- //
- // TwoImageCell.m
- // 千模
- //
- // Created by MUMEI on 2018/6/7.
- // Copyright © 2018年 MUMEI. All rights reserved.
- //
- #import "TwoImageCell.h"
- #import "UILabel+LabelHeightAndWidth.h"
- @implementation TwoImageCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- }
- - (void)setModel:(PrivateModel *)model{
- _model = model;
- self.detailLabel.text = model.intro;
- [self buildLabelOne];
- NSString *now = [Helper getCurrentTimes];
- NSString *lastDay = [Helper getLastTimes];
- NSArray * dateNow = [now componentsSeparatedByString:@" "];
- NSArray * nowYMD = [dateNow[0] componentsSeparatedByString:@"-"];
- NSString * nowY = nowYMD[0];
- NSString * nowM = nowYMD[1];
- NSString * nowD = nowYMD[2];
- NSArray * dateLast = [lastDay componentsSeparatedByString:@" "];
- NSArray * lastYMD = [dateLast[0] componentsSeparatedByString:@"-"];
- NSString * lastY = lastYMD[0];
- NSString * lastM = lastYMD[1];
- NSString * lastD = lastYMD[2];
-
- NSArray * date = [model.pdate componentsSeparatedByString:@" "];
- NSString * date2 = date[0];
- NSArray * YMD = [date2 componentsSeparatedByString:@"-"];
- NSString * Y = YMD[0];
- NSString * M = YMD[1];
- NSString * D = YMD[2];
-
- if ([Y isEqualToString:nowY]) {
- if ([M isEqualToString:nowM]) {
- if ([D isEqualToString:nowD]) {
- D = @"今天";
- self.Day.text = @"";
- self.Month.text = @"";
- self.noMonth = YES;
- }
- }
- }
- if ([Y isEqualToString:lastY]) {
- if ([M isEqualToString:lastM]) {
- if ([D isEqualToString:lastD]) {
- D = @"昨天";
- self.Day.text = D;
- self.Month.text = @"";
- self.noMonth = YES;
- }
- }
- }
- if (!self.noMonth) {
- if([M isEqualToString:@"01"]){
- M = @"1";
- }else if ([M isEqualToString:@"02"]){
- M = @"2";
- }else if ([M isEqualToString:@"03"]){
- M = @"3";
- }else if ([M isEqualToString:@"04"]){
- M = @"4";
- }else if ([M isEqualToString:@"05"]){
- M = @"5";
- }else if ([M isEqualToString:@"06"]){
- M = @"6";
- }else if ([M isEqualToString:@"07"]){
- M = @"7";
- }else if ([M isEqualToString:@"08"]){
- M = @"8";
- }else if ([M isEqualToString:@"09"]){
- M = @"9";
- }else if ([M isEqualToString:@"10"]){
- M = @"10";
- }else if ([M isEqualToString:@"11"]){
- M = @"11";
- }else if ([M isEqualToString:@"12"]){
- M = @"12";
- }
- self.Day.text = D;
- self.Month.text = [NSString stringWithFormat:@"%@月",M];
- }
- for (int i=0; i<model.iteminfo.count; i++) {
- NSString *url = [model.iteminfo[i] objectForKey:@"url"];
- if (i==0) {
- [self.oneImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",imageURl,url]] placeholderImage:[UIImage imageNamed:@"jiazai"]];
- }else if (i==1){
- [self.twoImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",imageURl,url]] placeholderImage:[UIImage imageNamed:@"jiazai"]];
- }
- }
- self.oneImage.layer.masksToBounds = YES;
- UITapGestureRecognizer *OneTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toImage1:)];
- [self.oneImage addGestureRecognizer:OneTap];
- self.oneImage.userInteractionEnabled = YES;
-
- self.twoImage.layer.masksToBounds = YES;
- UITapGestureRecognizer *TwoTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toImage2:)];
- [self.twoImage addGestureRecognizer:TwoTap];
- self.twoImage.userInteractionEnabled = YES;
-
- NSLog(@"date = %@",[Helper sharedAccount].date);
- // if([[Helper sharedAccount].date isEqualToString:date2]){
- // self.Day.hidden = YES;
- // self.Month.hidden = YES;
- // }
- // [Helper sharedAccount].date = date2;
- if ([model.isditto isEqualToString:@"1"]) {
- self.Day.hidden = YES;
- self.Month.hidden = YES;
- }else{
- self.Day.hidden = NO;
- self.Month.hidden = NO;
- }
- }
- - (void)toImage1:(UITapGestureRecognizer*)recognizer{
- [self.delegate clickImage:_model andNum:0];
- }
- - (void)toImage2:(UITapGestureRecognizer*)recognizer{
- [self.delegate clickImage:_model andNum:1];
- }
- #pragma mark - labelOne SizeToFitHeight
- - (void)buildLabelOne
- {
- self.detailLabel.text = _model.intro;
- _detailLabel.font = [UIFont systemFontOfSize:15];
- _detailLabel.numberOfLines = 0;
- CGFloat height = [UILabel getHeightByWidth:_detailLabel.frame.size.width title:_detailLabel.text font:_detailLabel.font];
- if (height>80) {
- height = 80;
- }
- _detailLabel.frame = CGRectMake(210, 15, 135, height);
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- @end
|