通过读取plist文件中的一些字符串来播放一段序列帧的方法,好不好用自己试试[原创]

//自动播放序列帧的方法:传入序列帧的名称plit文件、控制播放序列帧的速度时间、控制序列帧播放次数<0为循环播放>
-(void)SequenceImageAnimation:(NSString*)plist SpeedTimer:(float)speed NumberOfTimer:(int)number{
    CGRect frame = CGRectMake(0, 0, 1024, 768);
	animationViewTwo = [[UIImageView alloc] initWithFrame:frame];
    NSMutableArray *mutableArray = [NSMutableArray array];
    NSString *path = [[NSBundle mainBundle] pathForResource:plist ofType:@"plist"];
    NSArray *array = [NSArray arrayWithContentsOfFile:path];
    for (int i = 0; i < [array count]; i++) {
        NSString *obj = [array objectAtIndex:i];
        NSLog(@"循环打印数组元素:  %@", obj);
        UIImage *imageNmae = [UIImage imageNamed:obj];
        [mutableArray insertObject:imageNmae atIndex:i];
    }
    animationViewTwo.animationImages = mutableArray;
	animationViewTwo.animationDuration = speed;//1.25;
	animationViewTwo.animationRepeatCount = number;//0
	[animationViewTwo startAnimating];
	[self.view addSubview:animationViewTwo];
	[animationViewTwo release];
}

animationViewTwo为一个UIImageView的对象,在此声明为全局变量。

这是根据书上的简单动画修改而成的一个方法。

这里是读取静态的plist文件。想想将数据存入到plist文件里面,在做一个类似的。有能里帮忙指点指点吧

posted on 2012-10-25 17:52  呓语若梦半浮生  阅读(666)  评论(0编辑  收藏  举报

导航