5
我試圖自定義UITabBarItem,但我有圖像的位置問題。UITabBarItem finishedImageSelected放置偏移標籤欄
的圖像尺寸爲81px X 49px中,相同的高度UITabBar。這是我如何設置圖像:
// AppDelegate
BlocosController *blocos = [[[BlocosController alloc] initWithManagedObjectContext:moc] autorelease];
UINavigationController *navBlocos = [[[UINavigationController alloc] initWithRootViewController:blocos] autorelease];
tabBarController = [[UITabBarController alloc] initWithManagedObjectContext:moc];
tabBarController.viewControllers = [NSArray arrayWithObjects: navData, navBlocos, navBairro, navAtualizar, nil];
// ...
// BlocosController.m
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.tabBarItem = [[[UITabBarItem alloc] initWithTitle:TITLE image:nil tag:10] autorelease];
[[self tabBarItem] setFinishedSelectedImage:[UIImage imageNamed:@"tab_bar_blocos_selected"] withFinishedUnselectedImage:[UIImage imageNamed:@"tab_bar_blocos_unselected"]];
}
return self;
}
我已經在谷歌搜索,發現this tutorial,代碼使用相同的API,因爲我用和按預期工作。本文中的代碼與我的代碼行爲相似,但由於它們的背景是相同的顏色,所以它被錯誤地放置了。
爲什麼finishedImageSelected和unselected放置與tab選項卡不對齊?如何解決它?
我遇到了同樣的問題... – meadlai