• UIImageView


    #import "AppDelegate.h"

    @interface AppDelegate ()

    @end

    @implementation AppDelegate

    - (void)dealloc

    {

        self.window = nil;

        [super dealloc];

    }

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

        // Override point for customization after application launch.

        self.window = [[[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds] autorelease];

        

        

        self.window.backgroundColor = [UIColor whiteColor];

        [self.window makeKeyAndVisible];

        

        self.window.rootViewController = [[UIViewController alloc] init];

        UIImage *image = [UIImage imageNamed:@"image"];

        //创建imageview

        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)];

        

        imageView.backgroundColor = [UIColor redColor];

        

        //设置图片

        imageView.image = image;

        imageView.layer.borderWidth = 1;

        imageView.clipsToBounds = YES;

        //停靠模式

        //imageView.contentMode = UIViewContentModeTop;

        

        

        [self.window addSubview:imageView];

        [imageView release];

        

        //通过图片来创建

        UIImageView *imageView2 = [[UIImageView alloc]initWithImage:image];

        

        imageView2.center = CGPointMake(52, 48);

        

        //[self.window addSubview:imageView2];

        [imageView2 release];

        

        //获取动态图片的数组

        NSMutableArray *images = [NSMutableArray arrayWithCapacity:4];

        for (int i = 0; i < 4; i++) {

            UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"Button_foot%d", i+1]];

            [images addObject:image];

    }

        UIImageView *imageView3 = [[UIImageView alloc]initWithFrame:CGRectMake(50, 300, 100, 50)];

        //需要播放的图片

        imageView3.animationImages = images;

        //设置总播放时间

        imageView3.animationDuration = 2;

        //设置播放循环次数  缺省0 表示无限循环

        imageView3.animationRepeatCount = 0;

        

        [self.window addSubview:imageView3];

        [imageView3 release];

        //开启动画

        [imageView3 startAnimating];

        

        //停止动画

        //    [imageView3 stopAnimating];

        

        

        

        

        

        

        

        

    //----------------------------------------------------------

        

    //用户交互使能  默认no

        imageView3.userInteractionEnabled = YES;

        

        

        //点击手势, 不带参数

        //    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap)];

        //点击手势, 带参数

        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap:)];

        //给imageView3添加手势

        

        [imageView3 addGestureRecognizer:tap];

        [tap release];

        

        

        

        

        return YES;

    }

    - (void)onTap:(UITapGestureRecognizer *)tap

    {

        //获取添加手势的视图

        UIImageView *imageView = (UIImageView *)tap.view;

        [imageView stopAnimating];

    }

    - (void)onTap

    {

        NSLog(@"tap");

    }

  • 相关阅读:
    CodeBlocks 中fopen函数不支持命令 “r”
    【转载】分享一些Qt学习资源,欢迎下载
    【转载】知乎答案----孙志岗----Google 发布了程序员养成指南,国内互联网巨头是否也有类似的指南和课程推荐
    【转载】谷歌公司推荐的程序员必修课(英文教程)
    【转载】张逸--ThoughtWorks(中国)程序员读书雷达
    在windows环境下,为什么要用Notepad++编辑?
    【转载】池建强--趣谈个人建站
    JAVA入门第二季 第一章 类和对象
    CAP理论总结
    分布式通信方式之消息队列之RocketMQ
  • 原文地址:https://www.cnblogs.com/chunji/p/5257455.html
Copyright © 2020-2023  润新知