在iOS8系統下,UITabbar上的item自定義背景色和圖片問題

在iOS8系統下,UITabbar上的item自定義背景色和圖片,初始設置了紅色沒效果系統默認顏色-藍色

解決方法:

//選擇的圖片

    UITabBar *tabBar = self.tabBar;

    UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];

    UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1];

    UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2];

   tabBarItem1.title = @"title1";

    tabBarItem2.title = @"title2";

     UIImage* selectedImage = [UIImage imageNamed:@"xxxx.png"];

  //聲明這張圖片用原圖(別渲染)

    selectedImage = [selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    [tabBarItem1 setFinishedSelectedImage:selectedImage withFinishedUnselectedImage:[UIImage imageNamed:@"xxx.png"]];

    [tabBarItem2 setFinishedSelectedImage:[UIImage imageNamed:@"xxxx.png"]withFinishedUnselectedImage:[UIImage imageNamed:@"xxxx.png"]];

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章