我有一个tabBar,我想自定义标签栏中的项目.我想阻止标题的显示(通过将标题设置为nil很容易实现),并将图标位置重置为中心垂直位置.有没有人知道如何做到这一点?
谢谢.
我的iPhone应用程序在视图底部有一个标签栏控制器 - 此刻我有三个按钮.但是,我想添加更多,但为了这样做,我需要将三个按钮中的最后一个按钮变为"更多..."按钮,因为否则其他按钮上的文本会相互碰撞.
我知道如果标签栏中有超过5个按钮,那么它会自动创建一个更多的按钮 - 但是有没有办法通过编辑功能手动调用它?
谢谢.
我希望拥有它,以便视图控制器的标题与标签栏项目的标题不同.
我在viewDidLoad中尝试了以下内容
[self setTitle:@"My title"];
[[self tabBarItem] setTitle:@"Search"];
Run Code Online (Sandbox Code Playgroud)
但是对第二个函数的调用似乎不起作用
根据Apple 文档
我正在尝试在UITabBarItem上设置自定义完成的已选择和未选择的图像,如下所示:
...
DetailViewController *vc1 = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];
UITabBarItem *vc1i = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemTopRated tag:100];
[vc1i setFinishedSelectedImage:[UIImage imageNamed:@"tab_bar_item_selected.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tab_bar_item_normal.png"]];
[vc1 setTabBarItem:vc1i];
...
Run Code Online (Sandbox Code Playgroud)
基本上正在发生的事情是TabBar加载得很好,它只是完全忽略了标签栏项目的自定义.
我的目标是iOS5 +
图像是30x30透明PNG并存在于项目中.无法弄清楚我在这里俯瞰什么,但一定是什么东西!
这是在tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath方法中调用的,ala Ray Wenderlich的教程
有人有主意吗?
谢谢!
我有一个标签栏控制器(它是一个基于标签栏的应用程序,因此标签栏位于MainWindow.xib上).在这个xib中,我添加了4个标签栏项目,并设置了所有标签栏项目的图像.因此,我面临两个问题:
1)图像是白色的,但是当我运行应用程序时,它显示标签栏项目上的所有图像为灰色.如何使其看起来与原始图像中的相同.
2)我有一个选定的图像,我想在当前选中的标签栏项目上添加.我该怎么办?
尼克代码后更新:
嘿,在iOS 5中,你必须在你的app委托中编写以下代码,用于设置选中和未选中的标签栏项目(类别解决方案仅适用于4):
if ([[[UIDevice currentDevice] systemVersion] floatValue]>4.9) {
NSString *selectedImageName,*unselectedImageName;
for (int counter = 0; counter < [self.tabBarController.tabBar.items count]; counter++) {
if (counter==0) {
selectedImageName = <someImagename>;
unselectedImageName = <someImagename>;
}
else if (counter==1) {
selectedImageName = <someImagename>;
unselectedImageName = <someImagename>;
}
.
.
else {
selectedImageName = <someImagename>;
unselectedImageName = <someImagename>;
}
UIImage *selectedImage = [UIImage imageNamed:selectedImageName];
UIImage *unselectedImage = [UIImage imageNamed:unselectedImageName];
UITabBarItem *item = [self.tabBarController.tabBar.items objectAtIndex:counter];
if ([item respondsToSelector:@selector(setFinishedSelectedImage:withFinishedUnselectedImage:)]) {
[item setFinishedSelectedImage:selectedImage withFinishedUnselectedImage:unselectedImage];
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试将60x60像素分配给tabBarItem.image:
self.tabBarItem.image = [UIImage imageNamed:@"tab_settings@2x.png"];
Run Code Online (Sandbox Code Playgroud)
我在HIG上读到,我应该为Retina显示器放置60x60像素图像.但我得到的是尺寸不正确的图像:

如果我把它设为30x30px,它看起来也很糟糕(不像Retina).
我正在将一个视图控制器推送到另一个视图控制器但是当我按下tabbar项时索引没有改变.如何在将视图从一个推送到另一个时更改所选索引.提前感谢.
如何在UITabBarItem上自定义徽章编号?
像这样的东西

我在我的AppDelegate.m文件中有这个代码,didFinishLaunchingWithOptions:以便我可以有一个自定义字体.
[[UITabBarItem appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor grayColor], UITextAttributeTextColor,
[UIFont fontWithName:@"Gotham-Medium" size:10], UITextAttributeFont, nil] forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], UITextAttributeTextColor,
[UIFont fontWithName:@"Gotham-Medium" size:10], UITextAttributeFont, nil] forState:UIControlStateHighlighted];
Run Code Online (Sandbox Code Playgroud)
字体更改按预期工作,但我在调试控制台中获得此输出:
button text attributes only respected for UIControlStateNormal, UIControlStateHighlighted and UIControlStateDisabled. state = 1 is interpreted as UIControlStateHighlighted.
这是我的应用程序的简历:
代码在方法中tabBarController(tabBarController: UITabBarController, shouldSelectViewController viewController: UIViewController) -> Bool.
self.selectedIndex = #,VC会显示,但没有动画.有没有办法实现相同的动作,如点击项目?谢谢uitabbaritem ×10
iphone ×8
ios ×6
objective-c ×4
uitabbar ×3
badge ×1
cocoa-touch ×1
ios5 ×1
ipad ×1
swift ×1