博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
transitionFromView方法的使用
阅读量:4357 次
发布时间:2019-06-07

本文共 2545 字,大约阅读时间需要 8 分钟。

transitionFromView方法的使用

 

效果

 

源码

////  ViewController.m//  TransitionFromView////  Created by YouXianMing on 16/5/30.//  Copyright © 2016年 YouXianMing. All rights reserved.//#import "ViewController.h"typedef enum : NSUInteger {        kBottomView = 1000,    kTopView,    } EViewControllerTag;@interface ViewController () {    UIView *redView;    UIView *yellowView;    UIView *containerView;}@end@implementation ViewController- (void)viewDidLoad {        [super viewDidLoad];        // ContainerView    containerView         = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 350)];    containerView.center  = self.view.center;    [self.view addSubview:containerView];        // BottomView    redView                 = [[UIView alloc] initWithFrame:containerView.bounds];    redView.tag             = kBottomView;    redView.backgroundColor = [UIColor redColor];    [containerView addSubview:redView];        // TopView    yellowView                 = [[UIView alloc] initWithFrame:containerView.bounds];    yellowView.tag             = kTopView;    yellowView.backgroundColor = [UIColor yellowColor];    [containerView addSubview:yellowView];        // Button    UIButton *button = [[UIButton alloc] initWithFrame:self.view.bounds];    [button addTarget:self action:@selector(buttonEvent:) forControlEvents:UIControlEventTouchUpInside];    [self.view addSubview:button];}- (void)buttonEvent:(UIButton *)button {        button.enabled = NO;        [UIView transitionFromView:[containerView viewWithTag:kTopView]                        toView:[containerView viewWithTag:kBottomView]                      duration:0.5f                       options:UIViewAnimationOptionTransitionFlipFromLeft                    completion:^(BOOL finished) {                                                button.enabled = YES;                                                if ([[containerView viewWithTag:kBottomView] isEqual:redView]) {                                                        [containerView insertSubview:yellowView belowSubview:redView];                            redView.tag    = kTopView;                            yellowView.tag = kBottomView;                                                    } else {                                                    [containerView insertSubview:redView belowSubview:yellowView];                            redView.tag    = kBottomView;                            yellowView.tag = kTopView;                        }                    }];}@end

 

细节

 

转载于:https://www.cnblogs.com/YouXianMing/p/5542634.html

你可能感兴趣的文章
探究X Window System运行原理与启动过程
查看>>
Arch 安装 gnome桌面
查看>>
SpringCloud学习笔记(9)----Spring Cloud Netflix之声明式 REST客户端 -Feign的使用
查看>>
Python的平凡之路(17)
查看>>
Git for Windows之使用SSH协议开通公钥免密登陆功能
查看>>
Identity Server4学习系列一
查看>>
计算机硬件-基础
查看>>
完成登录功能,用session记住用户名
查看>>
C++ code:剩余串排列
查看>>
网页播放器插件
查看>>
Python第三方库jieba(中文分词)入门与进阶(官方文档)
查看>>
【转】eclipse for java ee的tomcat配置(常见问题解决)
查看>>
QQMacMgr for Mac(腾讯电脑管家)安装
查看>>
特效:ListBox数据加载特效
查看>>
php分页功能limit
查看>>
PHP中开启和关闭错误信息的提示
查看>>
C++ 中的一些错觉
查看>>
xshell配色方案
查看>>
使用注解实现 bean 转 csv
查看>>
iOS相机去黑框
查看>>