开发者

how do i create a sliding menu in xcode iphone like the main android menu sliding menu?

开发者 https://www.devze.com 2023-03-23 23:40 出处:网络
ive been looking all over the web for an example of a sliding menu described in the title. All i need is to know what item from the iphone library i should be looking at to make this开发者_如何学JAVA,

ive been looking all over the web for an example of a sliding menu described in the title. All i need is to know what item from the iphone library i should be looking at to make this开发者_如何学JAVA, i dont want to take up somebodys time making them write out the code but a little direction will be appreciated?


we have created a sliding drawer in our iphone application, we have done this using following procedure:

  1. Create a UIView object in your View Controller in Interface builder.
  2. create the object of UIView in your view controller (do not forget to make it (IBOutlet) in .h file)
  3. Similarly create a button in both interface builder and view controller, along with it's action method.
  4. Link the objects in header file with objects in interface builder

In viewDidLoad of your view controller set frame of the view you want to slide, with button

    - (void)viewDidLoad {
[super viewDidLoad];

toOpenView.frame = CGRectMake(self.view.frame.size.width, toOpenView.frame.origin.y, 0, toOpenView.frame.size.height);

}

In click event of your button add following code

    -(IBAction)onOpenButtonClick:(id)sender
    {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.8];

if (toOpenView.frame.origin.x == self.view.frame.size.width/2)
{

    toOpenView.frame = CGRectMake(self.view.frame.size.width, toOpenView.frame.origin.y, 0, toOpenView.frame.size.height);
    openButton.frame = CGRectMake((self.view.frame.size.width - openButton.frame.size.width), openButton.frame.origin.y, openButton.frame.size.width, openButton.frame.size.height);

}
else
{
    toOpenView.frame = CGRectMake(self.view.frame.size.width/2, toOpenView.frame.origin.y, self.view.frame.size.width/2, toOpenView.frame.size.height);
    openButton.frame = CGRectMake((toOpenView.frame.size.width - openButton.frame.size.width), openButton.frame.origin.y, openButton.frame.size.width, openButton.frame.size.height);
}
[UIView commitAnimations];

}


This wil help you get started hopefully.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号