//
// HelloWorldViewController.h
// 图片浏览
//
// Created by mahongmin on 14-5-15.
// Copyright (c) 2014年 mahongmin. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface HelloWorldViewController : UIViewController {
NSArray *descArray;
CGAffineTransform transform;
}
@property (weak, nonatomic) IBOutlet UIImageView *myImage;
@property (weak, nonatomic) IBOutlet UILabel *num;
@property (weak, nonatomic) IBOutlet UILabel *desc;
@property (weak, nonatomic) IBOutlet UIView *settingView;
@property (weak, nonatomic) IBOutlet UISwitch *isNight;
- (IBAction)showImage:(UISlider *)sender;
- (IBAction)setting:(UIButton *)sender;
- (IBAction)changeNight:(UISwitch *)sender;
- (IBAction)zoom:(UISlider *)sender;
@end
//
// HelloWorldViewController.m
// 图片浏览
//
// Created by mahongmin on 14-5-15.
// Copyright (c) 2014年 mahongmin. All rights reserved.
//
#import "HelloWorldViewController.h"
@interface HelloWorldViewController ()
@end
@implementation HelloWorldViewController
- (void)viewDidLoad
{
[super viewDidLoad];
//得到descs.plist
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle pathForResource:@"descs" ofType:@"plist"];
descArray = [NSArray arrayWithContentsOfFile:path];
self.desc.text = descArray[0];
transform = self.myImage.transform;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
#pragma mark - 滑动划条,改变图片
- (IBAction)showImage:(UISlider *)sender {
int value = sender.value;
self.num.text = [NSString stringWithFormat:@"%d/16", value + 1];
NSString *fileName = [NSString stringWithFormat:@"%d.png", value];
UIImage *currentImage = [UIImage imageNamed:fileName];
self.myImage.image = currentImage;
self.desc.text = descArray[value];
}
#pragma mark - 点击设置,弹出测试层
- (IBAction)setting:(UIButton *)sender {
[UIView beginAnimations:NULL context:NULL];
[UIView setAnimationDuration:0.8];
CGRect tempFrame = self.settingView.frame;
if (tempFrame.origin.y == self.view.frame.size.height) {
tempFrame.origin.y -= self.settingView.frame.size.height;
} else {
tempFrame.origin.y += self.settingView.frame.size.height;
}
self.settingView.frame = tempFrame;
[UIView commitAnimations];
}
#pragma mark - 设置夜晚模式
- (IBAction)changeNight:(UISwitch *)sender {
if (self.isNight.isOn) {
self.view.backgroundColor = [UIColor grayColor];
} else {
self.view.backgroundColor = [UIColor whiteColor];
}
}
#pragma mark - 改变图片大小
- (IBAction)zoom:(UISlider *)sender {
self.myImage.transform = CGAffineTransformScale(transform, sender.value, sender.value);
}
@end
-