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,运行成功即可!

  • 相关阅读:
    工作总结
    JSON数据使用
    DataTable知识
    树形结构菜单
    区域树前后台
    跨域总结
    工作一年感想
    项目整体架构分析
    springboot 和 mongdb连接问题 Exception in thread "main" com.mongodb.MongoSecurityException:
    go函数、方法、接口笔记
  • 原文地址:https://www.cnblogs.com/hanjun/p/2731696.html
Copyright © 2011-2022 走看看