2011-11-28 2 views
1

UITabBar 뒤에서 밀어 넣고 싶은 UIView가 바로 위에 배치됩니다.UITabBar 바로 위에 UIView를 밀어 넣는 방법

이것은 작동하지 않습니다. 내 견해는 나타나지 않습니다. 이 같은

- (void)showNotificationBar 
{ 
    CGRect frame = CGRectMake(0, 500, 320, 32); 
    frame.origin.y = CGRectGetMaxY(self.parentViewController.tabBarController.tabBar.frame) - frame.size.height; 
    notificationBar.frame = frame; 

    [self.parentViewController.tabBarController.tabBar.superview insertSubview:notificationBar 
                    belowSubview:self.parentViewController.tabBarController.tabBar]; 

    [UIView animateWithDuration:0.5 animations:^{ 
     CGRect frame = notificationBar.frame; 
     frame.origin.y = CGRectGetMaxY(self.parentViewController.tabBarController.tabBar.frame); 
     notificationBar.frame = frame; 
    }]; 
} 
+0

알림 표시 줄이 탭 막대 (화면의 동일한 픽셀을 차지함)와 겹치기를 원하십니까, 아니면 탭 표시 줄의 북쪽에 있습니까? –

+0

탭바의 북쪽 –

답변

1

초기화 frame.origin.y : 당신이 모든보기에 표시하려면

frame.origin.y -= frame.size.height; 
1

, 당신이 할 수있는 : 애니메이션에서

frame.origin.y = self.tabBarController.tabBar.frame.origin.y; 

차단이처럼 설정 모든 것 : 모든 뷰의 맨 아래에 표시하거나 응용 프로그램의 윈도우에 표시하십시오. 나는 개인적으로이 두 번째 방법은 같은 더 나은 중복 코드를 방지 할 수 있기 때문에 :

CGFloat notificationBarHeight = 40.0f; 
UIView *notificationBar = [[UILabel alloc]initWithFrame:CGRectMake(0, self.tabBarController.tabBar.frame.origin.y - notificationBarHeight, 320, notificationBarHeight)]; 
[self.window insertSubview:notificationBar atIndex:[[self.window subviews]count]]; 
0

[self.view의 insertSubview : notificationView atIndex : 1]; 나를 위해 일했습니다 ...