UIViewAnimationTransition视图180度翻转效果

文章标签: ios开发
2014-11-7 9:18:29     11 人阅读    

#import "TurnViewController.h"

@implementation TurnViewController

- (void)dealloc
{
    [super dealloc];
}



-(void)doScale:(id)sender{
    UIView *centerView = [self.view viewWithTag:100];
    UIViewAnimationTransition trans = UIViewAnimationTransitionFlipFromLeft;
    
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0f];
    [UIView setAnimationTransition:trans forView:centerView cache:YES];
    [centerView exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
    [UIView commitAnimations];
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    CGRect rect = CGRectMake(30, 50, 250, 300);
    UIView *centerView = [[UIView alloc] initWithFrame:rect];
    [centerView setBackgroundColor:[UIColor whiteColor]];
    [centerView setTag:100];
    [self.view addSubview:centerView];
    [centerView release];

    rect = CGRectMake(0, 0, 250, 300);
    UIView *bView = [[UIView alloc] initWithFrame:rect];
    [bView setBackgroundColor:[UIColor blackColor]];
    [centerView addSubview:bView];
    [bView release];
    
    rect = CGRectMake(10, 10, 100, 30);
    UITextView *textView1 = [[UITextView alloc] initWithFrame:rect];
    [textView1 setText:@"反面内容"];
    [textView1 setBackgroundColor:[UIColor yellowColor]];
    [bView addSubview:textView1];
    [textView1 release];
    
    rect = CGRectMake(120, 250, 100, 30);
    UIButton *bButton = [[UIButton alloc] initWithFrame:rect];
    [bButton setTitle:@"翻到正面" forState:UIControlStateNormal];
    [bButton setBackgroundColor:[UIColor redColor]];
    [bButton addTarget:self action:@selector(doScale:) forControlEvents:UIControlEventTouchUpInside];
    [bView addSubview:bButton];
    [bButton release];
    
    
    rect = CGRectMake(0, 0, 250, 300);
    UIView *aView = [[UIView alloc] initWithFrame:rect];
    [aView setBackgroundColor:[UIColor whiteColor]];
    [centerView addSubview:aView];
    [aView release];
    
    rect = CGRectMake(10, 10, 100, 30);
    UITextView *textView = [[UITextView alloc] initWithFrame:rect];
    [textView setText:@"正面内容"];
    [textView setBackgroundColor:[UIColor yellowColor]];
    [aView addSubview:textView];
    [textView release];
    
    rect = CGRectMake(120, 250, 100, 30);
    UIButton * aButton = [[UIButton alloc] initWithFrame:rect];
    [aButton setTitle:@"翻到背面" forState:UIControlStateNormal];
    [aButton.titleLabel setTextColor:[UIColor whiteColor]];
    [aButton setBackgroundColor:[UIColor blackColor]];
    [aButton addTarget:self action:@selector(doScale:) forControlEvents:UIControlEventTouchUpInside];
    [aView addSubview:aButton];
    [aButton release];
    
    
    
    
    
    
    rect = CGRectMake(140, 400, 50, 50);
    UIButton * cButton = [[UIButton alloc] initWithFrame:rect];
    [cButton setTitle:@"翻" forState:UIControlStateNormal];
    [cButton.titleLabel setTextColor:[UIColor whiteColor]];
    [cButton setBackgroundColor:[UIColor blueColor]];
    [cButton addTarget:self action:@selector(doScale:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:cButton];
    [cButton release];


}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end


原文地址:http://www.itmmd.com/201411/138.html
该文章由 萌萌的IT人 整理发布,转载须标明出处。

于asp.net做大型门户网站合适吗!   上一篇
下一篇  使用RunAs命令运行资源管理器,从而以管理员权限进行文件操作

精彩回复
发表评论
姓名:       

《程序员app》专门为程序员量身定做!