//
// ViewController.m
// transform练习
//
// Created by 李博 on 16/1/14.
// Copyright © 2016年 libo. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIView *redview;
@end
@implementation ViewController
- (IBAction)didClickRotate {
[UIView animateWithDuration:2.0 animations:^{
self.redview.transform=CGAffineTransformRotate(self.redview.transform, M_PI_4);
}];
}
- (IBAction)didClickScale {
[UIView animateWithDuration:2.0 animations:^{
self.redview.transform=CGAffineTransformScale(self.redview.transform, 0.5, 0.5);
}];
}
- (IBAction)didClicktranslation {
[UIView animateWithDuration:2.0 animations:^{
self.redview.transform=CGAffineTransformTranslate(self.redview.transform, 5, 5);
}];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
________________________________________________________________________________________________________________________________________-
//
// ViewController.m
// 图片浏览器
//
// Created by 李博 on 16/1/14.
// Copyright © 2016年 libo. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *txtTitle;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UIButton *leftButton;
@property (weak, nonatomic) IBOutlet UIButton *rightButton;
@property (weak, nonatomic) IBOutlet UILabel *suoyin;
@property(nonatomic,assign) int index;
//第一步创建一个数组
@property(nonatomic,strong)NSArray *prcture;
@end
@implementation ViewController
- (IBAction)didClickLeftButton:(id)sender {
self.index--;
//取出prcture中的字典,并且接收
NSDictionary *dict = self.prcture[self.index];
//通过dict中的desc赋值给txtTitle
self.txtTitle.text=dict[@"desc"];
self.imageView.image =[UIImage imageNamed:dict[@"icon"]];
self.suoyin.text=[NSString stringWithFormat:@"%d/%ld",self.index + 1,self.prcture.count];
self.rightButton.enabled=(self.index>= self.prcture.count-1)?NO:YES;
self.leftButton.enabled=(self.index<=0)?NO:YES;
}
//下一张
- (IBAction)didClickRightButton:(id)sender {
//索引+1
self.index++;
//取出prcture中的字典,并且接收
NSDictionary *dict = self.prcture[self.index];
//通过dict中的desc赋值给txtTitle
self.txtTitle.text=dict[@"desc"];
//图片需要名字******
self.imageView.image =[UIImage imageNamed:dict[@"icon"]];
self.suoyin.text=[NSString stringWithFormat:@"%d/%ld",self.index + 1,self.prcture.count];
//按钮的边上判断
self.rightButton.enabled=(self.index>= self.prcture.count-1)?NO:YES;
self.leftButton.enabled=(self.index<=0)?NO:YES;
}
//数组的get方法的重写
-(NSArray *)prcture{
//做一个判断用来加载
if(_prcture==nil){
//获取images.plist的全路径
NSString *path =[[NSBundle mainBundle] pathForResource:@"images.plist" ofType:nil];
//加载给_pructure
_prcture = [NSArray arrayWithContentsOfFile:path];
}
//返回
return _prcture;
}
- (void)viewDidLoad {
[super viewDidLoad];
// 默认执行一次下一张
self.index=-1;
[self didClickRightButton:self.rightButton];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
________________________________________________________________________________________________________________________________________-
//
// ViewController.m
// 帧动画的播放
//
// Created by 李博 on 16/1/14.
// Copyright © 2016年 libo. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *donghua;
@end
@implementation ViewController
- (IBAction)button1 {
//1.创建可变数组
NSMutableArray *array =[NSMutableArray array];
//2.开始把图片放到数组中
for (int i=0; i<25; i++) {
//格式化字符串拼接
NSString *imgName =[NSString stringWithFormat:@"father%03d",i+1];
//根据图片名传递给图片
UIImage *img =[UIImage imageNamed:imgName];
//把图片赋值给数组
[array addObject:img];
}
//把数组传递给图片框
self.donghua.animationImages=array;
//2.设置动画的持续时间
self.donghua.animationDuration=0.1*self.donghua.animationImages.count;
//3.设置动画的重复次数
self.donghua.animationRepeatCount =2;
//4.启动动画
[self.donghua startAnimating];
}
- (IBAction)button2 {
[self donghuaPlaywithName:@"greenMan" num:28];
}
- (IBAction)button3 {
[self donghuaPlaywithName:@"gun" num:40];
}
- (IBAction)button4 {
[self donghuaPlaywithName:@"showLove" num:67];
}
- (IBAction)button5 {
[self donghuaPlaywithName:@"tangTiger" num:29];
}
- (IBAction)button6 {
[self donghuaPlaywithName:@"threeDog" num:50];
}
- (IBAction)button7 {
[self donghuaPlaywithName:@"water" num:40];
}
- (IBAction)button8 {
[self donghuaPlaywithName:@"offWork" num:14];
}
//创建一个方法进行封装
-(void)donghuaPlaywithName:(NSString *)donghuaName num:(int)num{
//判断动画是否正在执行
if (self.donghua.isAnimating) {
return;
}
//1.创建可变数组
NSMutableArray *array =[NSMutableArray array];
//2.开始把图片放到数组中
for (int i=0; i<num; i++) {
//格式化字符串拼接
NSString *imgName =[NSString stringWithFormat:@"%@%03d.png",donghuaName,i+1];
//根据图片名传递给图片
//用imageNamed加载的图片是有缓存的
//UIImage *img =[UIImage imageNamed:imgName];
//没有缓存的方法
//确定图片的完整路径
NSString *imgPath =[[NSBundle mainBundle]pathForResource:imgName ofType:nil];
//通过调用imageWithContentsOfFile:方法来传递图片
UIImage *img =[UIImage imageWithContentsOfFile:imgPath];
//把图片赋值给数组
[array addObject:img];
}
//把数组传递给图片框
self.donghua.animationImages=array;
//2.设置动画的持续时间
self.donghua.animationDuration=0.1*self.donghua.animationImages.count;
//3.设置动画的重复次数
self.donghua.animationRepeatCount =2;
//4.启动动画
[self.donghua startAnimating];
//5.动画完成后清除内存
[self.donghua performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:self.donghua.animationDuration];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end