简体   繁体   中英

Make a bar slide onto iPhone screen

I'm making an iPhone web page and in order to optimise it for the device have decided to hide the menu bar and replace it with one button at the top. When this button is click a menu bar drops down and allows the user to go to another page. I'm having a bit of trouble trying to get the bar to slide down and up. Any help is much appreciated.

You need to use to animate the view. For example if menu is the variable which holds an istance of your bar (320x50px) you can animate up and down from the top with this code:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.3];
if (menu.frame.origin.y == 0)
  menu.frame = CGRectMake(0, -50, 320, 50);
else
  menu.frame = CGRectMake(0, 0, 320, 50);

[UIView setAnimationDelegate:self];     
[UIView commitAnimations];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM