Use of the transitionFromView method, transitionfromview

Source: Internet
Author: User

Use of the transitionFromView method, transitionfromview

Use of the transitionFromView Method

 

Effect

 

Source code

/// 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 finished: [containerView viewWithTag: kTopView] toView: [containerView viewWithTag: kBottomView] duration: 0.5f options: Completed 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

 

Details

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.