如何在UINavigationBar下滑出UIView?

She*_*lam 2 iphone cocoa-touch objective-c uiview uiviewanimation

目前我正在显示一个从窗口顶部向下滑动到位置的UIView:

-(void)showNotificationBar
{
    [notificationBar setFrame: CGRectMake(0, 0, 320, 44)];
    [[[UIApplication sharedApplication] keyWindow] addSubview:notificationBar];

    [UIView animateWithDuration:0.5
                          delay:0.0
                        options: UIViewAnimationCurveEaseInOut
                     animations:^{
                         [notificationBar setFrame: CGRectMake(0, 59, 320, 32)];
                     } 
                     completion:^(BOOL finished){
                         NSLog(@"Done!");
                     }];
}
Run Code Online (Sandbox Code Playgroud)

我想从我的UINavigationBar下面滑出来.现在它正从窗口顶部滑动到导航栏的底部.我希望它从导航栏的底部滑动以显示自己.现在确切地知道如何做到这一点?

rob*_*off 9

您将notificationBar在窗口中添加所有其他视图.您需要将其添加为导航栏下方导航栏超级视图的子视图.

让我们说你UINavigationBar的财产self.navBar.试试这个:

- (void)showNotificationBar
{
    CGRect frame = CGRectMake(0, 0, 320, 44);
    frame.origin.y = CGRectGetMaxY(self.navBar.frame) - frame.size.height;
    notificationBar.frame = frame;

    [self.navBar.superview insertSubview:notificationBar belowSubview:self.navBar];

    [UIView animateWithDuration:0.5 animations:^{
        CGRect frame = notificationBar.frame;
        frame.origin.y = CGRectGetMaxY(self.navBar.frame);
        notificationBar.frame = frame;
    }];
}
Run Code Online (Sandbox Code Playgroud)