iOS 8 TabBar 圖片顯示真實顏色

來源:互聯網
上載者:User

標籤:blog   io   os   使用   ar   div   問題   on   cti   

“展信顏開” 我怎麼想到這個詞了呢……因為這個足以表達我現在的心情,有解決了一個問題,有了一個收穫。

早上小夥伴問我“用內建的tab改圖的顏色他會不顯示?改tabitem。”我記得是可以顯示的,但是他既然這樣問,就肯定是是經過實驗的,於是本來相對清閑的我 ,就開始了我的探索旅程

運行過以前的項目之後,我發現要是舊的代碼在iOS 8 上面沒有了效果首先附上以前的代碼

 [tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"selectImage.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"image.png"]];

  既然現在沒有效果了,就說明這個方法在iOS8上面可能沒有用了,點擊查看,果真如此

- (void)setFinishedSelectedImage:(UIImage *)selectedImage withFinishedUnselectedImage:(UIImage *)unselectedImage NS_DEPRECATED_IOS(5_0,7_0,"Use initWithTitle:image:selectedImage: or the image and selectedImage properties along with UIImageRenderingModeAlwaysOriginal");

  

這樣看來,此方法在iOS7上面雖然有效果,但是也不應該使用了,而是應該使用後面提供的新方法,由於本人悟性差了一點,試了幾次再找到了真確的使用方法

 UIImage * normalImage = [[UIImage imageNamed:@"image.png"]  imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; UIImage * selectImage = [[UIImage imageNamed:@"selectImage.png"]  imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; UITabBarItem * tabBarItem = [[UITabBarItem alloc]initWithTitle:@"" image:normalImage selectedImage:selectImage];

  

OK 算是圓滿解決 好開心呀;

iOS 8 TabBar 圖片顯示真實顏色

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.