Ios UIViewAnimation+;设置映像将导致内存问题
在我的应用程序中,我使用不同的图像进行左、右、上、下放大、缩小动画 在这里,我使用的方法来改变图像Ios UIViewAnimation+;设置映像将导致内存问题,ios,animation,Ios,Animation,在我的应用程序中,我使用不同的图像进行左、右、上、下放大、缩小动画 在这里,我使用的方法来改变图像 int j=7; -(void)changeImage{ j=j-1; if (j==0) { j=7; } NSString *str=[NSString stringWithFormat:@"BG_%d.JPG",j]; [imgView setImage:[UIImage imageNamed:str]]; } 注意:我正在创建
int j=7;
-(void)changeImage{
j=j-1;
if (j==0) {
j=7;
}
NSString *str=[NSString stringWithFormat:@"BG_%d.JPG",j];
[imgView setImage:[UIImage imageNamed:str]];
}
注意:我正在创建自定义动画,因此不想使用
imgView.animationImages
这是我的图像动画代码
[UIView animateWithDuration:ZOOM_ANIMATION_DURATION delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^{
imgView.transform = CGAffineTransformMakeScale(1.4,1.4);
} completion:^(BOOL finished) {
[UIView animateWithDuration:ZOOM_ANIMATION_DURATION delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^{
imgView.transform = CGAffineTransformMakeScale(1.0,1.0);
} completion:^(BOOL finished) {
[self animateLeft];
[self changeImage];
}];
问题:所以每当我设置图像时,内存就会增加7.0到8.0%,有没有更好的方法。
谢谢。您不应该使用+
imageNamed
,正如文档中所述,它缓存图像,只有在内存压力条件下才会将其逐出。尝试使用+imageWithContentsOfFile
如果图像大小相同,您不会看到如此巨大的增加