【发布时间】:2012-01-08 03:20:54
【问题描述】:
我有以下代码在UITabViewController 正上方显示一个小通知栏:
- (void)showNotificationBar
{
if(mentionsButton.hidden)
{
//DM button on the left
[dmButton setFrame:CGRectMake(20,-2, 140, 35)];
[directMessagesPill setFrame:CGRectMake(6, 7, 29, 20)];
[dmCountLabel setFrame:CGRectMake(11, 5, 19, 21)];
[directMessagesLabel setFrame:CGRectMake(43, 6, 81, 21)];
//Mentions on the right
[mentionsButton setFrame:CGRectMake(162,-2, 140, 35)];
[mentionsPill setFrame:CGRectMake(161, 7, 29, 20)];
[mentionCountLabel setFrame:CGRectMake(166, 6, 19, 21)];
[mentionsLabel setFrame:CGRectMake(193, 6, 86, 21)];
}
else
{
//Mentions on the left
[mentionsButton setFrame:CGRectMake(20,-2, 140, 35)];
[mentionsPill setFrame:CGRectMake(6, 7, 29, 20)];
[mentionCountLabel setFrame:CGRectMake(11, 5, 19, 21)];
[mentionsLabel setFrame:CGRectMake(43, 6, 81, 21)];
//DM on the right
[dmButton setFrame:CGRectMake(162,-2, 140, 35)];
[directMessagesPill setFrame:CGRectMake(161, 7, 29, 20)];
[dmCountLabel setFrame:CGRectMake(166, 5, 19, 21)];
[directMessagesLabel setFrame:CGRectMake(193, 6, 86, 21)];
}
if(!mentionsButton.hidden && !dmButton.hidden)
notificationDivider.hidden = NO;
if(!self.tabBarController.tabBar.hidden)
{
//CGRect frame = CGRectMake(0, 0, 320, 32);
CGRect frame = CGRectMake(0, 500, 320, 32);
//frame.origin.y = CGRectGetMaxY(self.navigationController.navigationBar.frame) - frame.size.height;
frame.origin.y = self.tabBarController.tabBar.frame.origin.y;
notificationBar.frame = frame;
//[self.navigationController.navigationBar.superview insertSubview:notificationBar belowSubview:self.navigationController.navigationBar];
[self.tabBarController.tabBar.superview insertSubview:notificationBar belowSubview:self.tabBarController.tabBar];
[UIView animateWithDuration:0.5 animations:^{
CGRect frame = notificationBar.frame;
//frame.origin.y = CGRectGetMaxY(self.navigationController.navigationBar.frame);
frame.origin.y -= frame.size.height;
notificationBar.frame = frame;
}];
}
else
{
CGRect frame = CGRectMake(0, 500, 320, 32);
frame.origin.y = self.navigationController.toolbar.frame.origin.y;
notificationBar.frame = frame;
[self.navigationController.toolbar.superview insertSubview:notificationBar belowSubview:self.navigationController.toolbar];
[UIView animateWithDuration:0.5 animations:^{
CGRect frame = notificationBar.frame;
frame.origin.y -= frame.size.height;
notificationBar.frame = frame;
}];
}
}
问题是,当我将标签切换到隐藏标签栏的UINavigationController 时,UIView 和 UIToolbar 之间存在差距。我怎样才能重新定位它以使其下降?
【问题讨论】:
标签: iphone objective-c cocoa-touch uiview uinavigationcontroller