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");

    }

  • 相关阅读:
    STL的相关知识
    有关欧拉通路/回路的一些资料整理
    差分约束
    BZOJ 2100: [Usaco2010 Dec]Apple Delivery
    BZOJ 2017: [Usaco2009 Nov]硬币游戏(A Coin Game)
    vijos 1282&1283&1284&1285 佳佳的魔法照片/魔法药水/魔杖/魔法阵
    BZOJ 1660: [Usaco2006 Nov]Bad Hair Day
    BZOJ 1602: [Usaco2008 Oct]牧场行走
    BZOJ 1647: [Usaco2007 Open]Fliptile 翻格子游戏
    BZOJ 1646: [Usaco2007 Open]Catch That Cow
  • 原文地址:https://www.cnblogs.com/chunji/p/5257455.html
Copyright © 2011-2022 走看看