내 TabBar의 하위보기로 ImageView를 추가했습니다 (세 개의 NavigationController가 있음). tabBarController의 탭 중 하나를 탭하면 imageView의 이미지가 그에 따라 변경됩니다 (이미지는 선택된 특정 탭과 선택되지 않은 다른 탭을 보여줍니다).
그러나 이미지는 항상 tabBar에 추가 줄을 표시합니다. tabBar의 한계를 넘은 것 같습니다. 내 이미지의 크기는 320x64 픽셀 (비 레티 나 iPhone) 및 640x128 픽셀 (레티 나 iPhone)입니다.
이미지 뷰와 tabBarController에 대해 인스턴스 var를 선언하는 방법은 다음과 같습니다.
@interface HomePageViewController ()<UITabBarControllerDelegate>
{
UIImageView* tabBarView;
UITabBarController *tabBarController;
}
-(UITabBarController *) configureTheTabBarControllerWithNavControllerAtIndex:(NSInteger)index
{
UINavigationController *customerCareNavController;
UINavigationController *accAndContactsNavController;
UINavigationController *purchaseOrderNavController;
CustomerCareViewController *custCareVC;
PurchaeOrderViewController *POController;
AccountsAndContactsViewController *accAndContactsController;
custCareVC = [[CustomerCareViewController alloc] initWithNibName:@"CustomerCareViewController_iPhone" bundle:NULL];
POController = [[PurchaeOrderViewController alloc] initWithNibName:@"PurchaeOrderViewController_iPhone" bundle:NULL];
accAndContactsController = [[AccountsAndContactsViewController alloc] initWithNibName:@"AccountsAndContactsViewController_iPhone" bundle:NULL];
customerCareNavController = [[UINavigationController alloc] initWithRootViewController:custCareVC];
purchaseOrderNavController = [[UINavigationController alloc] initWithRootViewController:POController];
accAndContactsNavController = [[UINavigationController alloc] initWithRootViewController:accAndContactsController];
tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = [NSArray arrayWithObjects:customerCareNavController,accAndContactsNavController,purchaseOrderNavController, nil];
switch (index) {
case 0:
tabBarController.selectedIndex = 0;
break;
case 1:
tabBarController.selectedIndex = 1;
break;
case 2:
tabBarController.selectedIndex = 2;
break;
}
tabBarView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tab_mypeople.png"]];
tabBarView.frame = CGRectMake(0, -15, 320, 64);
[tabBarController.tabBar addSubview:tabBarView];
tabBarController.delegate = self;
[self selectTabBarIndex:index];
[self presentViewController:tabBarController animated:YES completion:NULL];
return tabBarController;
}
-(void)tabBarController:(UITabBarController *)TBController didSelectViewController:(UIViewController *)viewController
{
NSUInteger indexSelected = [[TBController viewControllers] indexOfObject:viewController];
[self selectTabBarIndex:indexSelected];
}
- (void) selectTabBarIndex:(NSInteger)index
{
switch (index)
{
case 0:
tabBarView.image=[UIImage imageNamed:@"tab_myCalendar.png"];
break;
case 1:
tabBarView.image=[UIImage imageNamed:@"tab_myDetails.png"];
break;
case 2:
tabBarView.image=[UIImage imageNamed:@"TabBarItem_PO.png"];
break;
}
}
스크린 샷을보세요 ..
barStyle을 검정색으로 설정하면 다음과 같은 결과가 나타납니다.
선이 약간 흐려졌지만 여전히 보입니다 ..
헤이 나는 뭔가를 시도했고 작동합니다
tabBarView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tab_mypeople.png"]];
tabBarView.frame = CGRectMake(0, 0, 320, tabBarController.tabBar.frame.size.height);
그러나 이미지는 약간 늘어져 있습니다 ..
스트레칭없이 쓰세요 : 이거 매력적일 거에요 .. !!
tabBarController.tabBar.backgroundImage = [UIImage new];
tabBarController.tabBar.shadowImage = [UIImage new];
tabBarView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tab_mypeople.png"]];
tabBarView.frame = CGRectMake(0, -15, 320, 64);
[tabBarController.tabBar addSubView:tabBarView];
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다