Hello.

There is a view that with the help of animation comes up from behind the screen. There are buttons on it that should move with this view. Actually, how to make these buttons?

The view is animated as follows. There is a variable draw, if it == 1, then the view is removed, if 0, then the view floats back to the screen. When you click on a specific button occurs:

[UIView beginAnimations: nil context: nil]; [UIView setAnimationDuration:0.5]; [UIView setAnimationDelay:0]; myView.frame=CGRectMake(menu_x,menu_y,menu_width,menu_height-150*draw); [UIView commitAnimations]; draw=!draw 

When animating the view, the buttons remain in place. And how to make them move with the view?

  • @Troir, If you are given an exhaustive answer, mark it as correct (click the check mark next to the selected answer). - Nicolas Chabanovsky

1 answer 1

Where are the buttons? If they lie on the form, then they will move with it. In general, UIView beginAnimations and its associates are considered obsolete, although not prohibited even from output 4.0, it is more correct to use blocks (group of methods animateWithDuration:animations :)

UPD:

If the buttons are in the view, the view is resized and the buttons have to move on it, then you should either add to the animation (before [UIView commitAnimations]; ) your relative position of the buttons, for example, tying them to the bottom of the view. In addition, whether the view comes under the bar and shines through if it comes in, in my opinion, is also tuned, but I don’t remember how to drop it, but now there’s no time to look

  • The buttons lie on the view, and they move with the view if you move the view, respectively. I change it in height - and thus the buttons do not react to the change in appearance. And I change the view in height, not in the coordinate for the following reason: The view comes up on top of the screen, and there is a Navigation bar. If you just move the view, then it goes behind the bar and, as it were, shines through it. - Troir
  • updated the answer, you would immediately write that you change the size, it is not obvious from your code, since I have no idea how the original was originally - aknew