/? ViewController.m
//訪問系統相冊
//
// ?Created by lanou on 16/7/12.
// ?Copyright ? 2016年pingguo. All rights reserved.
//
#import"ViewController.h"
//遵守協議
@interfaceViewController()
@property(nonatomic,strong)UIButton*userbtn;
@end
@implementationViewController
- (void)viewDidLoad {
[superviewDidLoad];
//所有的能看得到的ui控件創建初始化方式都可以采用alloc ?initWithFrame
self.userbtn=[[UIButtonalloc]initWithFrame:CGRectMake(160,60,80,80)];
//設置顏色
self.userbtn.backgroundColor=[UIColorredColor];
//設置圓形半徑
self.userbtn.layer.cornerRadius=40;
self.userbtn.layer.masksToBounds=YES;
//添加點擊事件:去訪問系統相冊
[self.userbtnaddTarget:selfaction:@selector(setUserImage)forControlEvents:(UIControlEventTouchUpInside)];
//將按鈕添加到屏幕上面來
[self.viewaddSubview:self.userbtn];
}
//訪問系統相冊
-(void)setUserImage
{
UIImagePickerController*imagePicker=[[UIImagePickerControlleralloc]init];
//設置代理,到@interface后面遵守協議
imagePicker.delegate=self;
[selfpresentViewController:imagePickeranimated:YEScompletion:nil];
}
//這個方法是協議UIImagePickerControllerDelegate里面的,選擇圖片結束的時候就會自動調用
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(nullableNSDictionary *)editingInfo
{
//設置頭像
[self.userbtnsetBackgroundImage:imageforState:(UIControlStateNormal)];
//將系統相冊消失掉
[pickerdismissViewControllerAnimated:YEScompletion:nil];
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
- (IBAction)drink:(UIButton*)sender {
[selfsetTomCatAnimationWithName:@"drink"withCount:81];
/* ?NSMutableArray ?*images=[NSMutableArray ??array];
for (NSInteger ?i=0; i<81; i++) {
NSString ?*imageName=[NSString ?stringWithFormat:@"drink_%02ld.jpg",i];
UIImage ?*image=[UIImage ?imageNamed:imageName];
[images ?addObject:image];
}
self.tomCatView.animationImages=images;
self.tomCatView.animationDuration=80*0.075;
self.tomCatView.animationRepeatCount=1;
[self.tomCatView startAnimating]; ??*/
}
- (IBAction)pie:(UIButton*)sender {
[selfsetTomCatAnimationWithName:@"pie"withCount:24];
/* ?NSMutableArray ?*images=[NSMutableArray ??array];
for (NSInteger ?i=0; i<24; i++) {
NSString ?*imageName=[NSString ?stringWithFormat:@"pie_%02ld.jpg",i];
UIImage ?*image=[UIImage ?imageNamed:imageName];
[images ?addObject:image];
}
self.tomCatView.animationImages=images;
self.tomCatView.animationDuration=24*0.075;
self.tomCatView.animationRepeatCount=1;
[self.tomCatView startAnimating]; ???*/
}
- (IBAction)scratch:(UIButton*)sender {
[selfsetTomCatAnimationWithName:@"scratch"withCount:56];
/* ????NSMutableArray ?*images=[NSMutableArray ??array];
for (NSInteger ?i=0; i<56; i++) {
NSString ?*imageName=[NSString ?stringWithFormat:@"scratch_%02ld.jpg",i];
UIImage ?*image=[UIImage ?imageNamed:imageName];
[images ?addObject:image];
}
self.tomCatView.animationImages=images;
self.tomCatView.animationDuration=56*0.075;
self.tomCatView.animationRepeatCount=1;
[self.tomCatView startAnimating]; ??*/
}
- (IBAction)fart:(UIButton*)sender {
[selfsetTomCatAnimationWithName:@"fart"withCount:28];
/* ???NSMutableArray ?*images=[NSMutableArray ??array];
for (NSInteger ?i=0; i<28; i++) {
NSString ?*imageName=[NSString ?stringWithFormat:@"fart_%02ld.jpg",i];
UIImage ?*image=[UIImage ?imageNamed:imageName];
[images ?addObject:image];
}
self.tomCatView.animationImages=images;
self.tomCatView.animationDuration=28*0.075;
self.tomCatView.animationRepeatCount=1;
[self.tomCatView startAnimating]; ??*/
}
- (IBAction)cymbal:(UIButton*)sender {
[selfsetTomCatAnimationWithName:@"cymbal"withCount:13];
/* ??NSMutableArray ?*images=[NSMutableArray ??array];
for (NSInteger ?i=0; i<13; i++) {
NSString ?*imageName=[NSString ?stringWithFormat:@"cymbal_%02ld.jpg",i];
UIImage ?*image=[UIImage ?imageNamed:imageName];
[images ?addObject:image];
}
self.tomCatView.animationImages=images;
self.tomCatView.animationDuration=13*0.075;
self.tomCatView.animationRepeatCount=1;
[self.tomCatView startAnimating]; ???*/
}
- (IBAction)knockout:(UIButton*)sender {
[selfsetTomCatAnimationWithName:@"knockout"withCount:81];
/* ??NSMutableArray ?*images=[NSMutableArray ??array];
for (NSInteger ?i=0; i<81; i++) {
NSString ?*imageName=[NSString ?stringWithFormat:@"knockout_%02ld.jpg",i];
UIImage ?*image=[UIImage ?imageNamed:imageName];
[images ?addObject:image];
}
self.tomCatView.animationImages=images;
self.tomCatView.animationDuration=81*0.075;
self.tomCatView.animationRepeatCount=1;
[self.tomCatView startAnimating]; ???*/
}
- (IBAction)angry:(UIButton*)sender {
[selfsetTomCatAnimationWithName:@"angry"withCount:26];
/* ?NSMutableArray ?*images=[NSMutableArray ??array];
for (NSInteger ?i=0; i<26; i++) {
NSString ?*imageName=[NSString ?stringWithFormat:@"angry_%02ld.jpg",i];
UIImage ?*image=[UIImage ?imageNamed:imageName];
[images ?addObject:image];
}
self.tomCatView.animationImages=images;
self.tomCatView.animationDuration=26*0.075;
self.tomCatView.animationRepeatCount=1;
[self.tomCatView startAnimating]; ???*/
}
- (IBAction)stomach:(UIButton*)sender {
[selfsetTomCatAnimationWithName:@"stomach"withCount:34];
/* ?NSMutableArray ?*images=[NSMutableArray ??array];
for (NSInteger ?i=0; i<34; i++) {
NSString ?*imageName=[NSString ?stringWithFormat:@"stomach_%02ld.jpg",i];
UIImage ?*image=[UIImage ?imageNamed:imageName];
[images ?addObject:image];
}
self.tomCatView.animationImages=images;
self.tomCatView.animationDuration=34*0.075;
self.tomCatView.animationRepeatCount=1;
[self.tomCatView startAnimating]; ???*/
}
- (IBAction)footleft:(UIButton*)sender {
[selfsetTomCatAnimationWithName:@"footLeft"withCount:30];
/* ?NSMutableArray ?*images=[NSMutableArray ??array];
for (NSInteger ?i=0; i<30; i++) {
NSString ?*imageName=[NSString ?stringWithFormat:@"footLeft_%02ld.jpg",i];
UIImage ?*image=[UIImage ?imageNamed:imageName];
[images ?addObject:image];
}
self.tomCatView.animationImages=images;
self.tomCatView.animationDuration=30*0.075;
self.tomCatView.animationRepeatCount=1;
[self.tomCatView startAnimating];*/
}
- (IBAction)footright:(UIButton*)sender {
[selfsetTomCatAnimationWithName:@"footRight"withCount:30];
/* NSMutableArray ?*images=[NSMutableArray ??array];
for (NSInteger ?i=0; i<30; i++) {
NSString ?*imageName=[NSString ?stringWithFormat:@"footRight_%02ld.jpg",i];
UIImage ?*image=[UIImage ?imageNamed:imageName];
[images ?addObject:image];
}
self.tomCatView.animationImages=images;
self.tomCatView.animationDuration=30*0.075;
self.tomCatView.animationRepeatCount=1;
[self.tomCatView startAnimating]; ?*/
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end