zoukankan      html  css  js  c++  java
  • 用UIImageView作出动画效果

    #import "AppDelegate.h"
    
    @interface AppDelegate ()
    
    @end
    
    @implementation AppDelegate
    
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.
        self.window.backgroundColor = [UIColor whiteColor];
        
        // 先把要播放的画面顺序排好
        NSMutableArray *imageArray = [[NSMutableArray alloc] init];
        for (int i = 0; i < 6; i++) {
            NSString *imageNames = [NSString stringWithFormat:@"run%d.tiff",i+1];
            UIImage *image = [UIImage imageNamed:imageNames];
            [imageArray addObject:image];
        }
        
        // 使用UIImageView 播放
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 120, 80)];
        imageView.animationImages = imageArray;
        // 播放一次动画所需的时间
        imageView.animationDuration = 1.0;
        // 设置播放的次数,其中0为一直播放
        imageView.animationRepeatCount = 0;
        // 开始动画
        [imageView startAnimating];
        
        [self.window addSubview:imageView];
        
        [self.window makeKeyAndVisible];
        return YES;
    }
    
    @end
  • 相关阅读:
    字典列表元组的推导式使用方法
    算法之排序
    闭包与装饰器
    循环(打印一些小东西)
    iOS内存小知识
    NSset
    字典
    NSNumber
    NSString
    NSArray
  • 原文地址:https://www.cnblogs.com/lantu1989/p/4601255.html
Copyright © 2011-2022 走看看