美文网首页程序员
UI动态图的设计

UI动态图的设计

作者: 帅过吴彦祖 | 来源:发表于2016-03-12 15:59 被阅读287次

展现动态图

UIImageView*myView = [[UIImageView alloc] init];     //创建UIImageView对象

myView.frame=CGRectMake(100,100,200,200);

[self.view addSubview:myView];

[myView release];

NSMutableArray*arr = [[NSMutableArray alloc] init];     //创建可变数组用来装载UIImage对象

for(int i =0; i <5; i++) {     // for循环将图片添加进UIImage中

NSString*str = [NSString stringWithFormat:@"%02d.tiff", i+1];   //获得字符串名字

UIImage*image = [UIImageimage Named:str];      //通过静态图片名字创建UIImage对象

[arr addObject:image];         //再将UIImage对象装载到数组中

}

myView.animationImages= arr;         //将装载好静态图数组赋值给UIImageView自带的动画数组中

myView.animationRepeatCount=8;        //设置动画重复次数(默认无限次)

myView.animationDuration=0.1 *   arr.count;         //设置动画播放时间

[myView startAnimating];          //启动动画

循环中字符串名字前面的数字(如下图)的给入需要用 %2d自动填满

例如:要想实现 012  008 这样的三位数 就应当用 %3d。

相关文章

网友评论

    本文标题:UI动态图的设计

    本文链接:https://www.haomeiwen.com/subject/dspxlttx.html