0

我有以下代码来显示一个小通知栏权利UITabViewController以上:如何将我的UIView的位置位于屏幕的底部?

- (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; 
     }]; 
    } 
} 

的问题是,有这种UIView,当我切换标签到UINavigationController隐藏了的TabBar一个UIToolbar之间的间隙。我怎样才能重新定位它,使它下降?

回答

1

,如果我有understod您的问题正确这应该这样做:

我会做的就是把定位代码上的另一功能的通知栏,因为你也在这一段代码插入子视图。你应该把它形成在这里和在视图中这样做的UIViewController的负载方法和调用的UINavigationController。

甲特技到通知栏正确定位没有太多的麻烦。将使用工具栏y位置作为参考,因为它被自动更新。

CGrect frame = notificationBar.frame; 
frame.y = self.navigationController.toolbar.frame.origin.y - notificationBar.frame.size.height; 
notificationBar.frame = frame; 

我希望这有助于。

相关问题