如何在xcode中创建一个滑动菜单iphone像主菜单滑动菜单? [英] how do i create a sliding menu in xcode iphone like the main android menu sliding menu?

查看:368
本文介绍了如何在xcode中创建一个滑动菜单iphone像主菜单滑动菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已经在网络上查看标题中描述的滑动菜单的示例。所有我需要的是知道什么项目从iphone库我应该看着做这个,我不想占用某些时间,让他们写出代码,但一个方向将赞赏?

$ b $我们已经在我们的iphone应用程序中创建了一个滑动抽屉,我们使用以下过程:



ol>

  • 在界面构建器中在您的视图控制器中创建一个UIView对象。

  • 在视图控制器中创建UIView的对象)in .h file)

  • 同样在界面构建器和视图控制器中创建一个按钮及其操作方法。

  • 包含界面构建器中对象的头文件

  • 在视图控制器的viewDidLoad中设置要滑动的视图的框架, p>

       - (void)viewDidLoad {
    [super viewDidLoad];

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

    }



    按钮添加以下代码

       - (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。尺寸。

    }
    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。高度);
    }
    [UIView commitAnimations];

    }


    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, 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];
    

    }

    这篇关于如何在xcode中创建一个滑动菜单iphone像主菜单滑动菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆