#import"ViewController.h"
@interfaceViewController()
@property(weak,nonatomic)IBOutletUIImageView*tomcatview;
@end
@implementationViewController
- (void)viewDidLoad {
[superviewDidLoad];
}
- (IBAction)eatbirdaction:(UIButton*)sender {
NSMutableArray*images = [NSMutableArrayarray];
for(NSIntegeri =0;i <40; i++) {//根据i来加载图片,然后添加到可变数组images
NSString*imagename = [NSStringstringWithFormat:@"eat_%02ld.jpg",i];
UIImage*image = [UIImageimageNamed:imagename];
[imagesaddObject:image];
}
self.tomcatview.animationImages= images;
self.tomcatview.animationDuration=40*0.075;
self.tomcatview.animationRepeatCount=1;
[self.tomcatviewstartAnimating];
}
- (IBAction)cymbalaction:(UIButton*)sender {//创建可变数组images,
NSMutableArray*images = [NSMutableArrayarray];
for(NSIntegeri =0;i <13; i++) {//根据i来加载图片,然后添加到可变数组images
NSString*imagename = [NSStringstringWithFormat:@"cymbal_%02ld.jpg",i];//根据格式化的图片名加载图片
UIImage*image = [UIImageimageNamed:imagename];
[imagesaddObject:image];//将图片image添加到images中
}
self.tomcatview.animationImages= images;//设置图片数组
self.tomcatview.animationDuration=14*0.075;//设置动画时长
self.tomcatview.animationRepeatCount=1;//设置动画播放次数
[self.tomcatviewstartAnimating];//开始动画
}
- (IBAction)drinkaction:(UIButton*)sender {NSMutableArray*images = [NSMutableArrayarray];
for(NSIntegeri =0;i <81; i++) {//根据i来加载图片,然后添加到可变数组images
NSString*imagename = [NSStringstringWithFormat:@"drink_%02ld.jpg",i];
UIImage*image = [UIImageimageNamed:imagename];
[imagesaddObject:image];
}
self.tomcatview.animationImages= images;//设置图片数组
self.tomcatview.animationDuration=81*0.075;//设置动画时长
self.tomcatview.animationRepeatCount=1;//设置动画播放次数
[self.tomcatviewstartAnimating];//开始动画
}
- (IBAction)fartaction:(UIButton*)sender {NSMutableArray*images = [NSMutableArrayarray];
for(NSIntegeri =0;i <28; i++) {//根据i来加载图片,然后添加到可变数组images
NSString*imagename = [NSStringstringWithFormat:@"fart_%02ld.jpg",i];
UIImage*image = [UIImageimageNamed:imagename];
[imagesaddObject:image];
}
self.tomcatview.animationImages= images;//设置图片数组
self.tomcatview.animationDuration=28*0.075;//设置动画时长
self.tomcatview.animationRepeatCount=1;//设置动画播放次数
[self.tomcatviewstartAnimating];//开始动画
}
- (IBAction)pieaction:(UIButton*)sender {NSMutableArray*images = [NSMutableArrayarray];
for(NSIntegeri =0;i <24; i++) {//根据i来加载图片,然后添加到可变数组images
NSString*imagename = [NSStringstringWithFormat:@"pie_%02ld.jpg",i];
UIImage*image = [UIImageimageNamed:imagename];
[imagesaddObject:image];
}
self.tomcatview.animationImages= images;//设置图片数组
self.tomcatview.animationDuration=24*0.075;//设置动画时长
self.tomcatview.animationRepeatCount=1;//设置动画播放次数
[self.tomcatviewstartAnimating];//开始动画
}
- (IBAction)scratchaction:(UIButton*)sender {NSMutableArray*images = [NSMutableArrayarray];
for(NSIntegeri =0;i <56; i++) {//根据i来加载图片,然后添加到可变数组images
NSString*imagename = [NSStringstringWithFormat:@"scratch_%02ld.jpg",i];
UIImage*image = [UIImageimageNamed:imagename];
[imagesaddObject:image];
}
self.tomcatview.animationImages= images;//设置图片数组
self.tomcatview.animationDuration=56*0.075;//设置动画时长
self.tomcatview.animationRepeatCount=1;//设置动画播放次数
[self.tomcatviewstartAnimating];//开始动画
}
- (IBAction)footrightaction:(UIButton*)sender {NSMutableArray*images = [NSMutableArrayarray];
for(NSIntegeri =0;i <30; i++) {//根据i来加载图片,然后添加到可变数组images
NSString*imagename = [NSStringstringWithFormat:@"footRight_%02ld.jpg",i];
UIImage*image = [UIImageimageNamed:imagename];
[imagesaddObject:image];
}
self.tomcatview.animationImages= images;//设置图片数组
self.tomcatview.animationDuration=30*0.075;//设置动画时长
self.tomcatview.animationRepeatCount=1;//设置动画播放次数
[self.tomcatviewstartAnimating];//开始动画
}
- (IBAction)footleftaction:(UIButton*)sender {NSMutableArray*images = [NSMutableArrayarray];
for(NSIntegeri =0;i <30; i++) {//根据i来加载图片,然后添加到可变数组images
NSString*imagename = [NSStringstringWithFormat:@"footLeft_%02ld.jpg",i];
UIImage*image = [UIImageimageNamed:imagename];
[imagesaddObject:image];
}
self.tomcatview.animationImages= images;//设置图片数组
self.tomcatview.animationDuration=30*0.075;//设置动画时长
self.tomcatview.animationRepeatCount=1;//设置动画播放次数
[self.tomcatviewstartAnimating];//开始动画
}
- (IBAction)stomachaction:(UIButton*)sender {NSMutableArray*images = [NSMutableArrayarray];
for(NSIntegeri =0;i <34; i++) {//根据i来加载图片,然后添加到可变数组images
NSString*imagename = [NSStringstringWithFormat:@"stomach_%02ld.jpg",i];
UIImage*image = [UIImageimageNamed:imagename];
[imagesaddObject:image];
}
self.tomcatview.animationImages= images;//设置图片数组
self.tomcatview.animationDuration=34*0.075;//设置动画时长
self.tomcatview.animationRepeatCount=1;//设置动画播放次数
[self.tomcatviewstartAnimating];//开始动画
}
- (IBAction)knockoutaction:(UIButton*)sender {NSMutableArray*images = [NSMutableArrayarray];
for(NSIntegeri =0;i <81; i++) {//根据i来加载图片,然后添加到可变数组images
NSString*imagename = [NSStringstringWithFormat:@"knockout_%02ld.jpg",i];
UIImage*image = [UIImageimageNamed:imagename];
[imagesaddObject:image];
}
self.tomcatview.animationImages= images;//设置图片数组
self.tomcatview.animationDuration=81*0.075;//设置动画时长
self.tomcatview.animationRepeatCount=1;//设置动画播放次数
[self.tomcatviewstartAnimating];//开始动画
}
- (IBAction)angryaction:(UIButton*)sender {NSMutableArray*images = [NSMutableArrayarray];
for(NSIntegeri =0;i <26; i++) {//根据i来加载图片,然后添加到可变数组images
NSString*imagename = [NSStringstringWithFormat:@"angry_%02ld.jpg",i];
UIImage*image = [UIImageimageNamed:imagename];
[imagesaddObject:image];
}
self.tomcatview.animationImages= images;//设置图片数组
self.tomcatview.animationDuration=26*0.075;//设置动画时长
self.tomcatview.animationRepeatCount=1;//设置动画播放次数
[self.tomcatviewstartAnimating];//开始动画
}
访问系统相册
#import"ViewController.h"
@interfaceViewController()//遵守协议
@property(nonatomic,strong)UIButton*userbtn;
@end
@implementationViewController
- (void)viewDidLoad {
[superviewDidLoad];
//所有能看到的ui控件创建初始化方式都可以采用alloc initwithframe
self.userbtn= [[UIButtonalloc]initWithFrame:CGRectMake(160,30,60,60)];
//设置属性
self.userbtn.backgroundColor= [UIColorredColor];
//设置圆形半径
self.userbtn.layer.cornerRadius=30;
//切去圆弧外围
self.userbtn.layer.masksToBounds=YES;
//添加点击事件:去访问系统相册
[self.userbtnaddTarget:selfaction:@selector(setuserimage)forControlEvents:(UIControlEventTouchUpInside)];
//添加到视图
[self.viewaddSubview:self.userbtn];
}
-(void)setuserimage//访问系统相册
{
UIImagePickerController*imagepinker = [[UIImagePickerControlleralloc]init];
//设置代理,到@interface
imagepinker.delegate=self;
//弹出系统相册
[selfpresentViewController:imagepinkeranimated:YEScompletion:nil];
}
//这个方法是协议UIImagePickerController里面的,选择图片结束会自动调用
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(nullableNSDictionary *)editingInfo{
//设置头像
[self.userbtnsetBackgroundImage:imageforState:UIControlStateNormal];
//将系统相册消失掉
[pickerdismissViewControllerAnimated:YEScompletion:nil];
}
网友评论