zoukankan      html  css  js  c++  java
  • 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");

    }

  • 相关阅读:
    排序算法之快速排序
    设计模式之原型模式
    设计模式之门面模式
    第五十四课 树中节点的插入操作
    第五十三课 树中节点的查找操作
    第五十二课 树的存储结构与实现
    第五十一课 树的定义与操作
    第五十课 排序的工程应用示例
    第四十九课 归并排序和快速排序
    第四十八课 冒泡排序和希尔排序
  • 原文地址:https://www.cnblogs.com/chunji/p/5257455.html
Copyright © 2011-2022 走看看