[英]iPhone tab bar with custom buttons and scrollview
I'm trying to get a tab bar effect not unlike Russell Quinn's Creative Review app . 我正在尝试获得标签栏效果,与Russell Quinn的Creative Review应用程序不同 。 The tab bar swipes across, which I have figured out, but the tab bar style itself is unlike anything I've seen on the iPhone (though it looks so simple!).
我已经弄清楚了标签栏的滑动,但是标签栏样式本身与我在iPhone上看到的任何东西都不一样(尽管看起来很简单!)。
It has square buttons with a space between, and each button has a select/active/inactive state. 它具有在各个按钮之间留有空格的方形按钮,并且每个按钮都具有选择/活动/不活动状态。 I'm having a hard time seeing how this can be a tab bar, but i don't know any other way.
我很难看到它如何成为选项卡栏,但我不知道其他任何方式。 Can someone explain this?
有人可以解释吗?
EDIT: 编辑:
thanks to yukla for the guidance, I got it working using uibutton
. 感谢yukla的指导,我使用
uibutton
使其工作。 It was pretty basic and fairly embarrassing that I couldn't think this up... in my rootviewcontroller.m
, I tossed this in after i synthesized homeBtn
. 我无法想到这一点,这是非常基本且令人尴尬的……在我的
rootviewcontroller.m
,我在合成homeBtn
之后把它扔了homeBtn
。
- (UIButton *) homeBtn {
homeBtn = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
homeBtn.frame = CGRectMake(0, 0, 100, 45);
[homeBtn setTitle:@"Home" forState:UIControlStateNormal];
[homeBtn setTitle:@"Home" forState:UIControlStateSelected];
[homeBtn setBackgroundImage:[UIImage imageNamed:@"normal.png"] forState:UIControlStateNormal];
[homeBtn setBackgroundImage:[UIImage imageNamed:@"disabled.png"] forState:UIControlStateDisabled];
[homeBtn setBackgroundImage:[UIImage imageNamed:@"selected.png"] forState:UIControlStateSelected];
[homeBtn setBackgroundImage:[UIImage imageNamed:@"highlighted.png"] forState:UIControlStateHighlighted];
[homeBtn setBackgroundImage:[UIImage imageNamed:@"highlighted+selected.png"] forState:(UIControlStateHighlighted | UIControlStateSelected)];
[homeBtn addTarget:self action:@selector(switchPages:) forControlEvents:UIControlEventTouchUpInside];
return homeBtn;
}
Just subclass it from UISwipeView and you're all set. 只需从UISwipeView对其进行子类化就可以了。
how about a scroll view with buttons instead of a tab bar?? 用按钮而不是标签栏的滚动视图怎么样? you can have different image/background for normal/selected/disabled state.
您可以为正常/选定/禁用状态使用不同的图像/背景。 but then you'll have to write your own code for loading the different views.
但随后您必须编写自己的代码以加载不同的视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.