gpt4 book ai didi

ios - 修复弹出滚动菜单的动画

转载 作者:行者123 更新时间:2023-12-01 18:49:52 26 4
gpt4 key购买 nike

我正在尝试通过激活 UIbutton 制作一个从按钮向上滑动的菜单。当你按下按钮时,一个 UIscrollView 从底部向上滑动。当 UIbutton 被激活和未被激活时,该按钮也会停留在滑动菜单上方。它应该是这样的:enter image description here

我在实际项目中将屏幕锁定为纵向模式,问题是当您按下按钮时。 UIscrollView 滑动到屏幕中间,当你再次按下按钮时,它只会向下移动几下。并且按钮不会随 UIscrollView 一起移动。我想让它像上图一样出现 UI scrollView 和 Unbutton 并在屏幕视口(viewport)下方下降。这就是我的实际项目的样子 - http://s4.postimg.org/dlvxnffbx/unnamed.png

以下是 viewcontroller.m 中用于动画的代码。

#import "ViewController.h"

@interface ViewController ()


@end

@implementation ViewController
@synthesize scrollView;

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
draw1 = 0;
scrollView.frame = CGRectMake(0, 300, 480, 55);
[scrollView setContentSize:CGSizeMake(480, 55)];

openMenu.frame = CGRectMake(220, 270, 60, 30);
}
- (IBAction)OpenMenu:(id)sender {
if (draw1 ==0) {
draw1 = 1;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

[UIButton beginAnimations:nil context:nil];
[UIButton setAnimationDuration:0.5];
[UIButton setAnimationDelay:0.0];
[UIButton setAnimationCurve:UIViewAnimationCurveEaseOut];

scrollView.frame = CGRectMake(0, 245, 568, 55);
openMenu.frame = CGRectMake(220, 200, 60, 30);

[self.view bringSubviewToFront:scrollView];

[UIView commitAnimations];
} else {
draw1 = 0;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

[UIButton beginAnimations:nil context:nil];
[UIButton setAnimationDuration:0.5];
[UIButton setAnimationDelay:0.0];
[UIButton setAnimationCurve:UIViewAnimationCurveEaseOut];

scrollView.frame = CGRectMake(0, 300, 568, 55);
openMenu.frame = CGRectMake(220, 270, 60, 30);

[self.view bringSubviewToFront:scrollView];

[UIView commitAnimations];
}
}
@end

最佳答案

您是否尝试过更换:

if (draw1 ==0) {
draw1 = 1;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

[UIButton beginAnimations:nil context:nil];
[UIButton setAnimationDuration:0.5];
[UIButton setAnimationDelay:0.0];
[UIButton setAnimationCurve:UIViewAnimationCurveEaseOut];

scrollView.frame = CGRectMake(0, 245, 568, 55);
openMenu.frame = CGRectMake(220, 200, 60, 30);

[self.view bringSubviewToFront:scrollView];

[UIView commitAnimations];
} else {
draw1 = 0;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

[UIButton beginAnimations:nil context:nil];
[UIButton setAnimationDuration:0.5];
[UIButton setAnimationDelay:0.0];
[UIButton setAnimationCurve:UIViewAnimationCurveEaseOut];

scrollView.frame = CGRectMake(0, 300, 568, 55);
openMenu.frame = CGRectMake(220, 200, 60, 30);

[self.view bringSubviewToFront:scrollView];

[UIView commitAnimations];
}

和 :
    if (draw1 ==0) {
draw1 = 1;
[UIView animateWithDuration:0.5
delay:0.0
options: UIViewAnimationOptionCurveEaseOut
animations:^{
scrollView.frame = CGRectMake(0, 1000, 568, 55);
openMenu.frame = CGRectMake(220, 200, 60, 30);
}
completion:^(BOOL finished){
NSLog(@"Done!");
}];
} else {
draw1 = 0;
[UIView animateWithDuration:0.5
delay:0.0
options: UIViewAnimationOptionCurveEaseOut
animations:^{
scrollView.frame = CGRectMake(0, 300, 568, 55);
openMenu.frame = CGRectMake(220, 270, 60, 30);
}
completion:^(BOOL finished){
NSLog(@"Done!");
}];
}

关于ios - 修复弹出滚动菜单的动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32011096/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com