2012-01-26 4 views
5

UITabBarItem을 사용자 정의하려고하는데 이미지의 위치에 문제가 있습니다.UITabBarItem finishedImageSelected가 탭 바를 오프셋으로 배치했습니다.

enter image description here

화상 사이즈는로서의 UITabBar 81px X 1600 픽셀, 동일한 높이이다. 내가 사용으로, 코드가 같은 API를 사용하여 내가 구글에서 검색 및 this tutorial을 발견했습니다

// 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; 
} 

예상대로 작동합니다 : 이것은 내가 이미지를 설정하는 방법입니다.이 기사의 코드는 마치 내 동작과 비슷하지만 배경이 같은 색이기 때문에 올바르게 배치되었다는 환상이 있습니다.

왜 finishedImageSelected이고 선택되지 않은 탭 탭이 정렬되지 않은 위치에 있습니까? 그것을 고치는 방법?

+0

같은 문제가 발생했습니다 ... – meadlai

답변

1

올바른 방법으로이를 수행하고 게시물을 작성했습니다 : felipecypriano.com/2012/02/27/….

기본적으로 finishedImage는 아이콘 및 배경 아이콘이 아니므로 imageInset 속성을 조정하여 배경과 함께 사용할 수 있습니다.

관련 문제