我要去另一頁,另一頁有UITabbarcontroller
。圖標圖像不顯示在iOS 7的tabbar上?
有:
- 首頁2 CutPipe 3件4法蘭5.設置
現在這五個名字都出現了,但我有沒有顯示這五個圖標和圖像屏幕顯示黑色和如果我做clearcolor然後屏幕顯示灰色。
我也想要如何控制高度UITabbarcontroller
。
我的問題是圖標圖像不顯示在tabbar上。
我還在UITabbar上添加背景圖像,並在圖標圖像上添加。但它沒有顯示。
這是我的代碼。在您的標籤實現以下
rvc_Home.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Home" image:[[UIImage imageNamed:@"home.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[UIImage imageNamed:HOME_SELECTED_IMAGE]];
編輯
添加代碼:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
// Retrieve the last view name
NSInteger firstValue = [[NSUserDefaults standardUserDefaults] integerForKey:@"firstValue"];
if (firstValue == 10) {
[self method_Tabs];
}
}
-(void)method_Tabs{
// Set the name of the view
[[NSUserDefaults standardUserDefaults] setInteger:11 forKey:@"firstValue"];
my_Tabbar = [[UITabBarController alloc] init]; // how to control height of my_Tabbar?
// my_Tabbar.view.frame=CGRectMake(0, 100, 320,30); // is there any way to control this
// my_Tabbar.view.backgroundColor = [UIColor redColor];
my_Tabbar.tabBar.barTintColor = [UIColor clearColor];
self.tabBarController.tabBar.translucent = false;
// this will give selected icons and text your apps tint color
my_Tabbar.tabBar.tintColor = [UIColor blueColor];
[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Bold" size:13.0f],
NSForegroundColorAttributeName : [UIColor colorWithRed:.5 green:.5 blue:.5 alpha:1]
} forState:UIControlStateNormal];
Homepage_AdvancePipeOffset *VC_1 = [[Homepage_AdvancePipeOffset alloc] initWithNibName:nil bundle:nil];
Apo_Cut_Pipe *VC_2 = [[Apo_Cut_Pipe alloc] initWithNibName:nil bundle:nil];
Apo_Fitting *VC_3 = [[Apo_Fitting alloc] initWithNibName:nil bundle:nil];
Apo_Flange *VC_4 = [[Apo_Flange alloc] initWithNibName:nil bundle:nil];
Apo_Setting *VC_5 = [[Apo_Setting alloc] initWithNibName:nil bundle:nil];
UINavigationController *rvc_Home = [[UINavigationController alloc] initWithRootViewController: VC_1];
UINavigationController *rvc_CutPipe = [[UINavigationController alloc] initWithRootViewController: VC_2];
UINavigationController *rvc_Fitting = [[UINavigationController alloc] initWithRootViewController: VC_3];
UINavigationController *rvc_Flange = [[UINavigationController alloc] initWithRootViewController: VC_4];
UINavigationController *rvc_Setting = [[UINavigationController alloc] initWithRootViewController: VC_5];
rvc_Home.tabBarItem.image =[UIImage imageNamed:@"home.png"];
rvc_CutPipe.tabBarItem.image =[UIImage imageNamed:@"icon_cut_pipe.png"];
rvc_Fitting.tabBarItem.image =[UIImage imageNamed:@"icon_fittings.png"];
rvc_Flange.tabBarItem.image =[UIImage imageNamed:@"icon_flanges.png"];
rvc_Setting.tabBarItem.image =[UIImage imageNamed:@"icon_settings.png"];
[email protected]"Home";
VC_1.tabBarController.tabBar.tag = 1;
[email protected]"CutPipe";
VC_2.tabBarController.tabBar.tag = 2;
[email protected]"Fitting";
VC_3.tabBarController.tabBar.tag = 3;
[email protected]"Flange";
VC_4.tabBarController.tabBar.tag = 4;
[email protected]"Setting";
VC_5.tabBarController.tabBar.tag = 5;
NSArray* controllers = [NSArray arrayWithObjects: rvc_Home,rvc_CutPipe,rvc_Fitting,rvc_Flange, rvc_Setting, nil];
[my_Tabbar setViewControllers: controllers animated:NO];
[self.view addSubview:my_Tabbar.view];
my_Tabbar.selectedIndex=4;
[self.navigationController pushViewController:my_Tabbar animated:YES];
}
圖像將不會顯示如果太大了。你有沒有嘗試減小圖像的幀大小?如果它適用於小圖標圖像,請嘗試[icon finder](https://www.iconfinder.com/)。 – GoGreen
圖標大小僅爲每張圖片120 * 98 – Tina
請嘗試圖片尺寸小於或等於48 x 32. – GoGreen