iOS 包含 setFinishedSelectedImage:withFinishedUnselectedImage: 用于自定义标签栏。我创建了一些高度为 49 的纹理,我在底部看到了一个奇怪的黑色边框。然后,在添加了一个 alpha 通道后,我意识到问题在于图像向上偏移了大约 4 个点。我发给你截图。而且,这个也有同样的问题(黑色怪线),虽然很难看到。 http://kurrytran.blogspot.com.es/2011/10/ios-5-tutorial-creating-custom-tab-bar.html
这是代码: UIImage *selectedImage0 = [UIImage imageNamed:@"count_button_pressed"]; UIImage *unselectedImage0 = [UIImage imageNamed:@"count_button_released"];
UIImage *selectedImage1 = [UIImage imageNamed:@"date_button_pressed"];
UIImage *unselectedImage1 = [UIImage imageNamed:@"date_button_released"];
UIImage *selectedImage2 = [UIImage imageNamed:@"stats_button_pressed"];
UIImage *unselectedImage2 = [UIImage imageNamed:@"stats_button_released"];
UITabBar *tabBar = self.tabBar;
UITabBarItem *item0 = [tabBar.items objectAtIndex:0];
UITabBarItem *item1 = [tabBar.items objectAtIndex:1];
UITabBarItem *item2 = [tabBar.items objectAtIndex:2];
[item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0];
[item1 setFinishedSelectedImage:selectedImage1 withFinishedUnselectedImage:unselectedImage1];
[item2 setFinishedSelectedImage:selectedImage2 withFinishedUnselectedImage:unselectedImage2];
你知道会发生什么吗?提前致谢。