=
#import "CHViewController.h" @interface CHViewController (){ NSArray *_allDescs; } @end @implementation CHViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. //设置图片描述 NSBundle *bundle = [NSBundle mainBundle]; NSString *path = [bundle pathForResource:@"descs" ofType:@"plist"]; _allDescs = [NSArray arrayWithContentsOfFile:path];//因为只需要加载一次就可以 NSLog(@"%@",_allDescs); _imageDesc.text = _allDescs[0]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } # pragma mark 点击设置按钮 - (IBAction)nightMode:(UISwitch *)sender { if(sender.on){ self.view.backgroundColor = [UIColor darkGrayColor]; }else{ self.view.backgroundColor = [UIColor whiteColor]; } } # pragma mark 对图像进行缩放 - (IBAction)imageSizeChange:(UISlider *)sender { //修改大小三种方式:frame bounds transform [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.4]; CGFloat scale = sender.value; //NSLog(@"%f",scale); _imageView.transform = CGAffineTransformMakeScale(scale, scale); [UIView commitAnimations]; } # pragma mark 控制设置view的上下 - (IBAction)setting { [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.0]; CGPoint tempCenter = _settingView.center; //NSLog(@"%@",tempCenter); if(_settingView.frame.origin.y == self.view.frame.size.height){ tempCenter.y -= _settingView.bounds.size.height; //NSLog(@"%@",tempCenter.x); }else{ tempCenter.y += _settingView.bounds.size.height; } _settingView.center = tempCenter; [UIView commitAnimations]; } # pragma mark slide值的改变 - (IBAction)sliderValueChange:(UISlider *)sender { int location = (int)sender.value; //设置图片 NSString *imageNamed = [NSString stringWithFormat:@"mg%d.jpg",location]; _imageView.image = [UIImage imageNamed:imageNamed]; //_imageView setImage:(UIImage *) //设置图片序号 NSString *imageNo = [NSString stringWithFormat:@"%d/6",location]; _imageNo.text = imageNo; //设置描述 int descNo = location - 1; //NSLog(@"%d--%@",no,allDescs[no]); _imageDesc.text = _allDescs[descNo]; NSLog(@"%f--%d--%@",sender.value,(int)sender.value,_allDescs[descNo]); } @end