iOS UIImageview实现简单动画
2013-12-06 16:48
429 查看
准备四张图片如下:
- (IBAction)start:(id)sender {
NSArray *animationImagesArr = [NSArrayarrayWithObjects:
[UIImageimageNamed:@"speaker_0.png"],
[UIImageimageNamed:@"speaker_1.png"],
[UIImageimageNamed:@"speaker_2.png"],
[UIImageimageNamed:@"speaker_3.gif"],
nil];
if (sperkerview==Nil) {
NSLog(@"NEW PALYER");
sperkerview = [[UIImageView
alloc]
init];
[sperkerview
setFrame:CGRectMake(200,
200, 80,
80)];
sperkerview.animationImages
= animationImagesArr;//animationImages属性返回一个存放动画图片的数组
sperkerview.animationDuration =0.25;
//浏览整个图片一次所用的时间
sperkerview.animationRepeatCount =0;
// 0 = loops forever动画重复次数
[sperkerviewstartAnimating];
[self.viewaddSubview:sperkerview];
[sperkerviewrelease];
}
}
-(IBAction)stop:(id)sender
{
[sperkerviewstopAnimating];
[sperkerviewremoveFromSuperview];
sperkerview =nil;
}
- (IBAction)start:(id)sender {
NSArray *animationImagesArr = [NSArrayarrayWithObjects:
[UIImageimageNamed:@"speaker_0.png"],
[UIImageimageNamed:@"speaker_1.png"],
[UIImageimageNamed:@"speaker_2.png"],
[UIImageimageNamed:@"speaker_3.gif"],
nil];
if (sperkerview==Nil) {
NSLog(@"NEW PALYER");
sperkerview = [[UIImageView
alloc]
init];
[sperkerview
setFrame:CGRectMake(200,
200, 80,
80)];
sperkerview.animationImages
= animationImagesArr;//animationImages属性返回一个存放动画图片的数组
sperkerview.animationDuration =0.25;
//浏览整个图片一次所用的时间
sperkerview.animationRepeatCount =0;
// 0 = loops forever动画重复次数
[sperkerviewstartAnimating];
[self.viewaddSubview:sperkerview];
[sperkerviewrelease];
}
}
-(IBAction)stop:(id)sender
{
[sperkerviewstopAnimating];
[sperkerviewremoveFromSuperview];
sperkerview =nil;
}
相关文章推荐
- Uevent 上报event事件给上层的详细讲解
- AS3中使用URLRequest发送POST请求
- The attribute value is undefined for the annotation type WebServlet解决方案
- UIActionSheet buttonTitleAtIndex 方法导致程序崩溃的问题
- UIAttachmentBehavior-动画效果:依附,关联
- iOS学习之UINavigationController详解与使用(二)页面切换和segmentedController
- iPhone开发之自定义UIActionSheet
- iOS拍照 相册选取 保存PNG图片到Documents下,并利用UICollectionView显示出来
- ant yui 对css,js进行压缩
- UISlider点击轴改变滑块位置
- UIActivityIndicatorView的两种形式
- 使用UIScrollView和UIPageControl实现一个简单的图片浏览功能
- [UIImage imageNamed:@""]使用误区
- Android中startActivity的permission检测与UID机制
- ios开发--UIImage转化成NSData
- ueditor 文件上传
- StringBuilder、StringBuffer、String
- UIImageWriteToSavedPhotosAlbum保存图片的方法
- EasyUI中combogrid的使用方法
- solr filter query的误用