簡體   English   中英

iOS 7 UITabBar徽章位置

[英]iOS 7 UITabBar badge position

有什么方法可以調整iOS 7中UITabBar徽章的位置? 徽章現在擋住了標簽欄圖標,超出了我的期望。

iOS 6: 在此處輸入圖片說明

IOS 7: 在此處輸入圖片說明

好像徽章被放置在相對於圖像的特定位置。 因此,如果您沒有圖像,則徽章位於tabBarItem的左上角。

因此,要定位徽章,請調整用於tabBarItem圖片的.png周圍的空白像素的邊框。

無法調整徽章的外觀。

如果您真的想讓它有所不同,我認為在UITabBar上實現自定義疊加應該很容易。 這樣,您可以在其中放置任何自定義文本,而不僅僅是數字。

如果可能,您能否提供設置標簽欄圖像的方法?

我遇到了與您相同的問題,並通過使用UIImageRenderingModeAlwaysOriginal進行了UIImageRenderingModeAlwaysOriginal

UIImage *image = // Your tab bar item image
UIImage *selected = // Your selected tab bar item image

image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
selected = [selected imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

controller.tabBarItem = [[UITabBarItem alloc] initWithTitle:title
                                                      image:image
                                              selectedImage:selected];

干杯!

iOS 7 SDK折舊了我們用於自定義標簽欄的3個關鍵方法

- (void)setFinishedSelectedImage:(UIImage *)selectedImage withFinishedUnselectedImage:(UIImage *)unselectedImage

- (UIImage *)finishedUnselectedImage

- (UIImage *)finishedSelectedImage

他們按照@Daniel Amitay的建議在文檔中提出了替代方案。

文檔在這里

https://developer.apple.com/library/ios/documentation/uikit/reference/UITabBarItem_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/occ/instm/UITabBarItem/setFinishedSelectedImage:withFinishedUnselectedImage

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM