好的我正在看iPhone iCal应用程序,并且好奇顶部栏是导航栏还是工具栏?香港专业教育学院尝试使用两者,但我也无法弄清楚如何改变按钮的大小,就像右上角的+按钮一样小...非常困惑..我假设它的导航栏,但当我阅读导航栏的说明,它说每当你要在栏上添加一个按钮或项目时,你就无法直接连接它......不知道怎么做...但是有人想帮忙解决这个问题吗?
答案 0 :(得分:6)
如果你提到this one
它不是UITabBar
,而是UINavigationBar
,最左边的按钮是UINavigationBar
的内置后退按钮,右边的按钮是一个额外的按钮,可以添加,它清楚地显示在{ {3}},要更改类型(即+按钮),只需使用
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonSystemItemAdd target:nil action:nil];
向UINavigationBar
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonSystemItemAdd target:nil action:nil];
rightButton.width=10;
rightButton.height=10;
UINavigationItem *item = [[UINavigationItem alloc] initWithTitle:@"Title"];
item.rightBarButtonItem = rightButton;
item.hidesBackButton = YES;
[bar pushNavigationItem:item animated:NO];
[rightButton release];
[item release];
但通常你会有一个导航控制器,你可以写:
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonSystemItemAdd target:nil action:nil];
self.navigationItem.rightBarButtonItem = rightButton;
[rightButton release];
希望这有帮助, 问候
答案 1 :(得分:2)
带有RED圈的顶栏是UINavigationaBar
&带有绿色圆圈的栏是自定义设计。
您可以使用以下编写的代码将系统定义的“添加”按钮添加到UINavigationaBar
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonSystemItemAdd target:nil action:nil];
答案 2 :(得分:0)
我意识到实际上你不需要代码就可以让按钮缩小到日历应用程序右上角的+按钮的大小。事实上,一旦你进入故事板。打开右侧的实用程序选项卡。然后打开属性检查器。在标识符的位置,下拉选项卡有选项。选择添加选项。