我試圖在我的應用程序中實現可隱藏的UITabBar。我製作了所有的動畫,並且效果很好。我只是遇到了一個問題,讓我的UIButton「pull-tab」顯示標籤欄。它不響應觸摸事件UIControlEventTouchUpInside。 我拉選項卡添加到UITabBar中的UITabBarController:將UIButton作爲子視圖添加到UITabBar
- (void)viewDidLoad
{
[super viewDidLoad];
//Add pull
pullButton = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *image = [UIImage imageNamed:@"TabBarPull.png"];
pullButton.frame = CGRectMake(self.tabBar.frame.size.width - image.size.width, -image.size.height + 3, image.size.width, image.size.height);
[pullButton setImage:image forState:UIControlStateNormal];
[pullButton addTarget:self action:@selector(pullBarTapped:) forControlEvents:UIControlEventTouchUpInside];
pullButton.userInteractionEnabled = YES;
[self.tabBar addSubview:pullButton];
}
這裏是標籤欄的樣子打開和關閉:
編輯:我確定問題是因爲按鈕超出了UITabBar的框架。看起來我將不得不把按鈕放在UITabBar之外...動畫噩夢。
那麼,它可能是你可以繼承UITabBar,弄清楚如何讓你的子類用於UITabBarController(它的子類),然後在你的UITabBar子類中創建一個更大的框架,讓UITabbar使用它的正常框架,但現在你的子類應該得到所有的水龍頭等。如果是我,我會首先嚐試在演示項目中執行UITabBar子類,只有當這些作品試圖讓它與所有其他機器一起工作時。祝你好運! – 2012-07-21 02:17:59
@Brandon Mcq嘿,我期待着同樣的事情 - 你有沒有想出一個好的解決方案?謝謝! – RyanG 2012-12-17 21:09:16
@Brandon Mcq剛剛看到你的github,看看這個謝謝! – RyanG 2012-12-17 21:21:39