ไม่มีไอคอนสีภายใน 'เพิ่มเติม' ของ UITabBar

ฉันได้รับไอคอนแท็บสีสำหรับแท็บต่างๆ ดังที่เห็นในภาพหน้าจอด้านล่าง

ป้อนคำอธิบายรูปภาพที่นี่

แต่เมื่อฉันคลิกเพิ่มเติมและดูแท็บเพิ่มเติม ฉันจะไม่เห็นไอคอนแท็บสี

ป้อนคำอธิบายรูปภาพที่นี่

วิธีรับไอคอนแท็บสีสำหรับแท็บ 'เพิ่มเติม' นี่คือรหัสของฉันใน didFinishLaunchingWithOptions ของ AppDelegate

UITabBar *tb = tabBarControllerProperty.tabBar;
        NSArray *itemsObject = tb.items;
        for(UITabBarItem *tabItem in itemsObject)
        {
            UIImage *imaged = tabItem.image;
            if([imaged respondsToSelector:@selector(imageWithRenderingMode:)])
            {
                tabItem.image = [imaged imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
            }
            else
            {
                tabItem.image = imaged;
            }
            tabItem.selectedImage = imaged;

        }

person Deepak Thakur    schedule 08.01.2014    source แหล่งที่มา
comment
คุณต้องการตั้งค่ารูปภาพในรายการเพิ่มเติมหรือไม่ ??   -  person iPatel    schedule 08.01.2014
comment
ไม่.. ฉันต้องการตั้งค่าไอคอนรูปภาพสีที่ฉันได้รับหลังจากคลิก 'เพิ่มเติม' อ้างอิงภาพหน้าจอที่ 2   -  person Deepak Thakur    schedule 08.01.2014


คำตอบ (1)


ลองสิ่งนี้

สำหรับการตั้งค่าตัวบ่งชี้การเลือก:

[[yourTabBarController tabBar] setSelectionIndicatorImage:[UIImage imageNamed:ImageName]];

สำหรับการตั้งค่าไอคอนแถบแท็บให้ใช้รหัสต่อไปนี้:

yourTabBarController.ViewController[0].tabBarItem = [[UITabBarItem alloc] initWithTitle:TitleForTabItem image:[[UIImage imageNamed:FirstTabIconImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[UIImage imageNamed:FirstTabIconImage]];

การใช้รายการแถบแท็บชุดนี้สำหรับ viewControllers อื่นด้วย

go on... :)

person Sujith Thankachan    schedule 08.01.2014
comment
วิธีการตั้งค่าไอคอนสีและตั้งชื่อรูปภาพสำหรับ 'startnew' 'contacts' และ 'logout' อ้างอิงภาพหน้าจอที่ 2 ฉันเพิ่ม [self.tabBarController.tabBar setSelectionIndicatorImage:[UIImage imageNamed:@img6.png]]; ใน initWithNibName ของชั้นเรียนและลองใช้ใน appDelegate ด้วย - person Deepak Thakur; 08.01.2014
comment
คุณสามารถใช้ไอคอนแถบแท็บเดียวกันได้ และจำเป็นต้องสร้างภาพตัวบ่งชี้การเลือกสำหรับแถบแท็บของคุณ จากนั้นตั้งค่าภาพตัวบ่งชี้การเลือกดังกล่าวตามด้านบน - person Sujith Thankachan; 08.01.2014
comment
รหัสต่อไปนี้ใน appdelegate ไม่ทำงานถ้า (self.tabBarControllerProperty.selectedIndex == 4) { [self.tabBarControllerProperty.tabBar setSelectionIndicatorImage:[UIImage imageNamed:@collaborations.png]]; } if(self.tabBarControllerProperty.selectedIndex == 5) { [self.tabBarControllerProperty.tabBar setSelectionIndicatorImage:[UIImage imageNamed:@contacts.png]]; } if(self.tabBarControllerProperty.selectedIndex == 6) { [self.tabBarControllerProperty.tabBar setSelectionIndicatorImage:[UIImage imageNamed:@logout.png]]; } - person Deepak Thakur; 08.01.2014
comment
ใช้ตัวบ่งชี้การเลือกเพียงครั้งเดียว และตั้งค่ารูปภาพแถบแท็บของคุณแยกกัน - person Sujith Thankachan; 08.01.2014