简体   繁体   English

如何为 iphone 应用程序制作自定义按钮菜单?

[英]how to make a custom button menu for iphone app ?

I want to create a custom menu, in the buttom of the screen, like this one:我想在屏幕的底部创建一个自定义菜单,如下所示:

自定义菜单

what is the best ui class should I use, I think it's not a Tabbar?我应该使用最好的 ui class 是什么,我认为它不是 Tabbar? Toolbar may be?工具栏可能是?

Any piece of code help to customize will be helpful.任何有助于自定义的代码都会有所帮助。 thanks.谢谢。

Just put 5 UIButton's with correct frame and correct UIImage for the button state.只需为按钮 state 放置 5 个具有正确框架的 UIButton 和正确的 UIImage。

The best way to do it is by manipulating UIButtons.最好的方法是操作 UIButtons。

Follow those steps:请按照以下步骤操作:

  • add UIButtons in IB在 IB 中添加 UIButtons
  • connect proper actions to the following methods in your UIViewController class将正确的操作连接到 UIViewController class 中的以下方法

. .

-(IBAction)setTabOne{
    [self resetButtons];
    [tabBTOne setBackgroundImage:[UIImage imageNamed:@"tabOne_on.png"] forState:UIControlStateNormal];
    [tabBTOne setSelected:YES];
    [tabBTOne setUserInteractionEnabled:NO];
}

-(IBAction)setTabTwo{
    [self resetButtons];
    [tabBTTwo setBackgroundImage:[UIImage imageNamed:@"tabTwo_on.png"] forState:UIControlStateNormal];
    [tabBTTwo setSelected:YES];
    [tabBTTwo setUserInteractionEnabled:NO];
}
...

-(void)resetButtons{
    [tabBTOne setSelected:NO];
    [tabBTTwo setSelected:NO];

    [tabBTOne setBackgroundImage:[UIImage imageNamed:@"tabOne.png"] forState:UIControlStateNormal];
    [tabBTTwo setBackgroundImage:[UIImage imageNamed:@"tabTwo.png"] forState:UIControlStateNormal];

    [tabBTOne setUserInteractionEnabled:YES];
    [tabBTTwo setUserInteractionEnabled:YES];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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