zoukankan      html  css  js  c++  java
  • 吸收效果,像是在Mac上的垃圾桶的效果一样

     1 #import "AppDelegate.h"
     2 #import <QuartzCore/QuartzCore.h>
     3 
     4 @interface AppDelegate ()
     5 @property (nonatomic ,strong)UIImageView *birdImage;
     6 @end
     7 
     8 @implementation AppDelegate
     9 
    10 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    11     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    12     // Override point for customization after application launch.
    13     self.window.backgroundColor = [UIColor whiteColor];
    14     // 创建UIImageView
    15     self.birdImage = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    16     //设置UIImageView可以操作
    17     self.birdImage.userInteractionEnabled = YES;
    18     // 添加图片
    19     self.birdImage.image = [UIImage imageNamed:@"bird"];
    20     // 轻拍手势
    21     UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAntion)];
    22     // 给UIImageView添加手势
    23     [self.birdImage addGestureRecognizer:tap];
    24     [self.window addSubview:self.birdImage];
    25  
    26     [self.window makeKeyAndVisible];
    27     return YES;
    28 }
    29 
    30 - (void)tapAntion
    31 {
    32     // 设置层的背景颜色
    33     self.window.layer.backgroundColor = [UIColor whiteColor].CGColor;
    34     // 创建动画
    35     CATransition *anim = [CATransition animation];
    36     //设置代理
    37     anim.delegate = self;
    38     // 设置动画时间
    39     anim.duration = 1.5;
    40     //吸收效果,像是在Mac上的垃圾桶的效果一样(私有API,没有列入官方API)
    41     anim.type = @"suckEffect";
    42     [[self.birdImage layer] addAnimation:anim forKey:@"suckEffect"];
    43     // 隐藏self.birdImage(若不隐藏,图片会保留在窗口)
    44     self.birdImage.hidden = YES;
    45 }
    46 
    47 @end
  • 相关阅读:
    2.4 Git 基础
    MySQL的连接命令
    linux中的ls、cd、pwd命令
    Vim 快速入门之基本命令
    linux 中查看进程、杀死进程、进入进程的命令
    linux下文件夹的创建、复制、剪切、重命名、清空和删除的命令
    Linux下tar压缩和解压缩命令详解
    用Windows远程桌面连接树莓派的方法
    MariaDB数据库安装完需要初始化操作
    linux设置服务为自动启动和关闭并禁用的命令
  • 原文地址:https://www.cnblogs.com/lantu1989/p/4603516.html
Copyright © 2011-2022 走看看