【问题标题】:Button flip animation out of frame on the uiviewuiview上的按钮翻转动画超出框架
【发布时间】:2016-07-01 23:17:28
【问题描述】:

更新,已解决

对不起我的英语,但我会尽力而为。

我的按钮翻转动画有问题。

我希望 UIButtons 填充 UIView。但是我该怎么做呢?

这是我的问题。 我在 UIView 中有两个 UIButton。 当我按下第一个按钮时,它会正确翻转,但是当我按下第二个按钮时,它已经翻转到 UIView 的大小仍然相同,但 UIButton 图像的大小正在更改为图像的原始大小,并且它还将图像移动到视图控制器的左上角。每次翻转都会重复同样的事情。

这是翻转动画代码。

- (IBAction) buttonPressedFlip {

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];

if (flipState == 0) {
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:buttonContainer cache:YES];

    [self.btn1 removeFromSuperview];
    [buttonContainer addSubview:btn2];
    flipState = 1;
}

else {
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:buttonContainer cache:YES];

    [self.btn2 removeFromSuperview];
    [buttonContainer addSubview:btn1];
    flipState = 0;
}

[UIView commitAnimations];

}

祝您有美好的一天,感谢您的帮助!

我这样解决了问题

- (IBAction) buttonPressedFlip {

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];

if (flipState == 0) {

    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:buttonContainer cache:YES];
    [self.buttonContainer bringSubviewToFront:btn2];
    flipState = 1;

}

else {

    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:buttonContainer cache:YES];
    [self.buttonContainer bringSubviewToFront:btn1];
    flipState = 0;

}

[UIView commitAnimations];

}

【问题讨论】:

    标签: ios objective-c animation uiview uibutton


    【解决方案1】:

    我解决了问题

    查看我的更新代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-05
      • 2011-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多