-2

我有一个 UIScrollView 和一个 UIButton。我正在使用块为它们设置动画,但是 UIScrollView 执行时按钮不会设置动画?你不能为这样的按钮设置动画吗?

任何帮助将不胜感激!

- (void)viewDidLoad
{

    [super viewDidLoad];

    draw1 = 0;
    scrollView.frame = CGRectMake(0, -200, 768, 200);
    [scrollView setContentSize:CGSizeMake(768, 200)];

    openMenu.frame = CGRectMake(680, 100, 55, 55);

}



- (IBAction)openMenu:(id)sender {

    if (draw1 == 0) {

        draw1 = 1;
        CGRect optionsDrawer = scrollView.frame;
        CGRect optionsButton = openMenu.frame;
        optionsDrawer.origin.y += 200;

        [UIView animateWithDuration:0.5
                         animations:^{
                             scrollView.frame = optionsDrawer;
                             openMenu.frame = optionsButton;
                         }];
    } else {

        draw1 = 0;

        CGRect optionsDrawer = scrollView.frame;
        CGRect optionsButton = openMenu.frame;
        optionsDrawer.origin.y -= 200;
        [UIView animateWithDuration:0.5
                         animations:^{
                             scrollView.frame = optionsDrawer;
                             openMenu.frame = optionsButton;
                         }];

    }

}
4

1 回答 1

0

啊! 我也忘了将原点添加到按钮!哎呀!

固定添加到每个:

optionsButton.origin.y += 200;
于 2013-09-04T16:16:41.047 回答