sequencing image using core animation, Recieving memory warnings

与世无争的帅哥 提交于 2019-12-01 20:25:44

问题


I am recieving memory warning using 100 of animating images so I tried to use Core Animation instead but that gives me the same problem. This is because I don't know how to use replaceSublayer in my current code

UIView* upwardView=[[UIView alloc]init];
[upwardView setFrame:CGRectMake(0, 0, 1024, 768)];
[self.view addSubview:upwardView];

NSArray *animationImages=[NSArray arrayWithObjects:[UIImage imageNamed:@"001.png"],[UIImage imageNamed:@"001.png"],[UIImage imageNamed:@"002.png"],[UIImage imageNamed:@"003.png"],....,nil];

CAKeyframeAnimation *animationSequence = [CAKeyframeAnimation animationWithKeyPath: @"contents"];
animationSequence.calculationMode = kCAAnimationLinear;
animationSequence.autoreverses = YES;
animationSequence.duration = 5.00;
animationSequence.repeatCount = HUGE_VALF;

NSMutableArray *animationSequenceArray = [[NSMutableArray alloc] init];
for (UIImage *image in animationImages)
{
    [animationSequenceArray addObject:(id)image.CGImage];
}
CALayer *layer = [upwardView layer];
animationSequence.values = animationSequenceArray;
[layer addAnimation:animationSequence forKey:@"contents"];

来源:https://stackoverflow.com/questions/18955031/sequencing-image-using-core-animation-recieving-memory-warnings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!