[英]How do i show image animation on iphone
這是我在當前項目中獲得的一些代碼。 我有一個循環,可將standy2圖像通過standby7.png放入數組中。 我正在使用imageWithContentsOfFile,因為這似乎在內存使用方面要好一些。
standbyAnimationImages = [[NSMutableArray alloc] init];
for (NSUInteger i=2; i<=7; i++) {
filename = [NSString stringWithFormat:@"standby%d", i];
[standbyAnimationImages addObject:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:filename ofType:@"png"]]];
}
imageViewAnimation.animationImages = standbyAnimationImages;
imageViewAnimation.animationDuration = 2;
imageViewAnimation.animationRepeatCount = 0;
[imageViewAnimation startAnimating];
希望這對您有所幫助。
將其拆分為單獨的PNG或JPG圖像,然后將每個幀加載到UIImageView
並使用其動畫方法。 在“動畫圖像”下查看UIImageView
文檔。 這很簡單。
如果將所有框架導出到單個圖像,則可以創建UIImage
視圖,請將animationImages
屬性設置為包含所有框架作為UIImages
的NSArray
。 然后調用[imageView startAnimating]
。
凱爾
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.