zoukankan      html  css  js  c++  java
  • 视图翻转

    1.新建一个Empty Application程序

    修改文件appDelegate.m

    在方法- (BOOL)application::添加以下代码:

    //视图,hanjun
    tview = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    tview.backgroundColor = [UIColor redColor];
    [self.window addSubview:tview];

    //创建按钮
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    // btn.titleLabel = @"翻转";
    [btn setTitle:@"翻转" forState:UIControlStateNormal];
    btn.frame = CGRectMake(100, 300, 100, 30);
    [btn addTarget:self
    action:@selector(animateAction:)
    forControlEvents:UIControlEventTouchUpInside];
    [self.window addSubview:btn];

    2.//按钮点击产生的事件(方法)

    - (void) animateAction:(id)sender
    {
    //动画部分
    //动画块
    [UIView beginAnimations:nil context:nil];//动画块的开始
    [UIView setAnimationDuration:0.75];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
    forView:tview
    cache:YES];
    [UIView commitAnimations];//结束动画
    }

    3.commad+r,运行成功即可!

  • 相关阅读:
    LeetCode 43 字符串相乘
    HDU 1031 Design T-Shirt
    HDU 1728 逃离迷宫
    HDU 1285 确定比赛名次
    HDU 1116 Plays on words
    HDU 1195 Open the lock
    HDU 1072 Nightmare
    HDU 1272 小希的迷宫
    HDU 1273 漫步森林
    HDU 1269 迷宫城堡
  • 原文地址:https://www.cnblogs.com/hanjun/p/2731696.html
Copyright © 2011-2022 走看看