2012-01-26 29 views
5

Tôi đang cố gắng tùy chỉnh UITabBarItem nhưng tôi đang gặp sự cố với vị trí của hình ảnh.UITabBarItem finishedImageSelected được đặt bù trừ thanh tab

enter image description here

Kích thước ảnh là 81px x 49px, chiều cao giống như UITabBar. Đây là cách tôi đặt hình ảnh:

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

Tôi đã tìm kiếm trên google và tìm thấy this tutorial, mã sử dụng API giống như tôi sử dụng và làm việc như mong đợi.Mã trong bài viết này hoạt động giống như của tôi, nhưng kể từ khi nền của họ là cùng một màu sắc có một ảo tưởng của nó đã được đặt chính xác.

Tại sao tùy chọn xongImageSelected và không được chọn được đặt không được đặt bằng tab tab? Làm thế nào để sửa chữa nó?

+0

Tôi đã gặp cùng sự cố ... – meadlai

Trả lời

1

Tôi đã tìm đúng cách để thực hiện việc này và tạo một bài đăng: felipecypriano.com/2012/02/27/….

Về cơ bản vấn đề là xongImage là biểu tượng không phải biểu tượng và nền, có thể sử dụng với nền bằng cách điều chỉnh thuộc tính imageInset.

Các vấn đề liên quan