// // ImageViewController.m // 千模 // // Created by MUMEI on 2018/7/1. // Copyright © 2018年 MUMEI. All rights reserved. // #import "ImageViewController.h" #import "CustomTextField.h" @interface ImageViewController () { UIImageView * inputImage; CustomTextField *textField; } @property (weak, nonatomic) IBOutlet UIImageView *Image; @property (weak, nonatomic) IBOutlet UIButton *dianZanBtn; @property (weak, nonatomic) IBOutlet UIButton *pingLunBtn; @property (weak, nonatomic) IBOutlet UILabel *dianZanLabel; @property (weak, nonatomic) IBOutlet UILabel *pingLunLabel; @property (weak, nonatomic) IBOutlet UIButton *dianZanBtn2; @property (weak, nonatomic) IBOutlet UIButton *pingLunBtn2; @property (weak, nonatomic) IBOutlet UILabel *dianZanNum; @property (weak, nonatomic) IBOutlet UILabel *pingLunNum; @property (weak, nonatomic) IBOutlet UILabel *introText; @property (weak, nonatomic) IBOutlet UIScrollView *scrollVIew; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *top; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottom; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *textBottom; @end @implementation ImageViewController { BOOL isZan; } - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title = @""; self.navigationController.navigationBar.barTintColor = [UIColor colorWithHexString:@"#333333"] ; if ([UIScreen spt_currentScreenMode]== LESScreenModeIPhoneX) { _top.constant = -24; _bottom.constant = 34; _textBottom.constant = 25; } UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom]; btn.frame = CGRectMake(0, 0, 40, 40); [btn setImage:[UIImage imageNamed:@"fanhui1"] forState:UIControlStateNormal]; btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0); [btn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:btn]; UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; nagetiveSpacer.width = -12;//这个值可以根据自己需要自己调整 self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, leftItem]; self.view.backgroundColor = [UIColor blackColor]; [self set]; UITapGestureRecognizer *Tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toDianZan:)];; [self.dianZanLabel addGestureRecognizer:Tap1]; self.dianZanLabel.userInteractionEnabled = YES; UITapGestureRecognizer *Tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toPingLun:)];; [self.pingLunLabel addGestureRecognizer:Tap2]; self.pingLunLabel.userInteractionEnabled = YES; inputImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, ScreenWidth+170, 400, 30)]; [inputImage setImage:[UIImage imageNamed:@"pinglunshurukuang"]]; inputImage.userInteractionEnabled = YES; inputImage.hidden = YES; textField = [[CustomTextField alloc]initWithFrame:CGRectMake(10, 0, 380, 30) placeholder:@"评论" clear:NO leftView:nil fontSize:17]; textField.delegate = self; textField.layer.borderWidth = 1.0; textField.layer.borderColor = [UIColor clearColor].CGColor; textField.returnKeyType = UIReturnKeyDone; [self.view addSubview:inputImage]; [inputImage addSubview:textField]; if([_model.islikes isEqualToString:@"0"]){ [_dianZanBtn setImage:[UIImage imageNamed:@"zan"] forState:UIControlStateNormal]; isZan = NO; }else if ([_model.islikes isEqualToString:@"1"]){ [_dianZanBtn setImage:[UIImage imageNamed:@"aixin"] forState:UIControlStateNormal]; isZan = YES; } } - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:NO animated:YES]; } -(void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; // self.navigationController.navigationBar.barTintColor = [UIColor colorWithHexString:@"#FFFFFF"] ; } - (void)toDianZan:(UITapGestureRecognizer*)recognizer { [self dianZanEvent]; } - (void)toPingLun:(UITapGestureRecognizer*)recognizer { [self pingLunEvent]; } -(void)backClick{ [self.navigationController popViewControllerAnimated:YES]; } - (void)setModel:(PrivateModel *)model{ _model = model; } - (void)set{ self.introText.text = _model.intro; NSMutableArray * photo = _model.iteminfo; // [self.Image sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",imageURl,[photo[_i] objectForKey:@"url"]]]]; NSMutableArray * dianZanArray = _model.privateInfo; self.dianZanNum.text = [NSString stringWithFormat:@"%ld",dianZanArray.count]; NSLog(@"text = %lu ,%ld",(unsigned long)dianZanArray.count,dianZanArray.count); NSMutableArray * pingLunArray = _model.recordinfo; self.pingLunNum.text = [NSString stringWithFormat:@"%ld",pingLunArray.count]; self.scrollVIew.contentSize = CGSizeMake(ScreenWidth*photo.count, 0); self.scrollVIew.showsHorizontalScrollIndicator = NO; self.scrollVIew.showsVerticalScrollIndicator = NO; self.scrollVIew.pagingEnabled = YES; for (int i=0; i