【问题标题】:Animation on uiview [closed]uiview上的动画[关闭]
【发布时间】:2013-07-24 11:26:37
【问题描述】:

我以编程方式创建了一个 UIView。现在我想用动画显示视图。我的代码如下。请注意,代码是在按钮单击事件上。

 view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 284)];
view1.backgroundColor = [UIColor redColor];
[self.view addSubview: view1];
UIButton *cancel = [UIButton buttonWithType:UIButtonTypeRoundedRect];
cancel.frame = CGRectMake(265, 0, 55, 20);
[cancel setTitle: @"Cancel" forState: UIControlStateNormal];
[cancel addTarget:self action:@selector(cancelView:) forControlEvents:UIControlEventTouchUpInside];

【问题讨论】:

  • 您应该指定“动画”的含义。你想要什么动画?
  • 我的意思是当我点击按钮时,视图通过不正常的适当动画显示
  • 有很多动画可能,你应该明确你想要什么。
  • 我还没有应用任何动画。所以我不知道。

标签: ios animation uiview


【解决方案1】:

试试看……

 [UIView beginAnimations: nil context: nil];
 [UIView setAnimationBeginsFromCurrentState: YES];
 [UIView setAnimationDuration: 0.5];
 view1.frame = CGRectMake(20,45,110,548); //Set frame according your choice
 [UIView commitAnimations];

希望我能帮上忙。

【讨论】:

  • 先生,它工作正常,但我们可以改变动画的风格,我的意思是另一个动画
  • @Nasir :如果它有效,那么您应该接受答案并放弃投票。根据您的选择设置动画时间。
  • @Nasir : [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:NO];
【解决方案2】:

将此用于显示动画的视图

https://github.com/kohtenko/KOPopupView

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-05
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 2011-11-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多