簡體   English   中英

如何創建半透明(背后有內容)UITabBar

[英]How to create translucent (with content behind it) UITabBar

我已經將UITabBar子類化並覆蓋了drawRect:方法,使其透明(並使其看起來像我需要的那樣)。 我遇到的問題是添加到UITabBarController的視圖沒有覆蓋整個屏幕但是在底部上方49個像素,所以即使我有透明的tabbar,我也看不到它背后的東西。

有沒有正確的方法我可以在UITabBarController中設置UIView的大小來覆蓋整個屏幕?

PS:我知道在tabbar后面顯示內容並不是一個好主意。 我不想在那里展示任何內容,只是藝術,這是每個視圖特有的,需要通過tabbar顯示。

如果你想在UITabBar后面有內容,我會看到兩個選項:

  • 不要使用UITabBarController -這肯定會工作,因為只要你想,你可以定位的意見,也不是那么難實現它。

  • 嘗試在視圖上關閉clipsToBounds並將一些視圖放在他的邊界之外。

     // UIViewController contained in UITabBarController: self.view.clipsToBounds = NO; UIView *viewBehindTabBar = [[UIView alloc] init]; viewBehindTabBar.frame = CGRectMake(0, self.view.bounds.size.height, self.view.bounds.size.width, 49); // autoresizing mask, background color, ... [self.view addSubview:viewBehindTabBar]; 

您只需創建一個UITabBar或UITabBarController類別並設置它的Alpha

就像是 :-

@implementation UITabBarController (Translucent)
- (void)createImage
{
     [self.tabBar setAlpha:0.1];
}
@end

您甚至可以在Drawrect中設置Alpha。

暫無
暫無

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

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