如何在侧面板越过中心面板的 iOS 中创建滑出式导航面板?
How to create a Slide-Out Navigation Panel in iOS where the side panel goes over the center panel?
我关注了 Tammy Coron this great tutorial。一切都很好,我明白它是如何工作的,但我想要实现的有点不同。我希望中央视图是“静态的”,可以这么说,侧面板与这个中央视图重叠。
所以我应该改变这部分:
UIView *childView = [self getLeftView];
[self.view sendSubviewToBack:childView];
[UIView animateWithDuration:SLIDE_TIMING delay:0 options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
_centerViewController.view.frame = CGRectMake(self.view.frame.size.width - PANEL_WIDTH, 0, self.view.frame.size.width, self.view.frame.size.height);
}
completion:^(BOOL finished) {
if (finished) {
_centerViewController.leftButton.tag = 0;
}
}];
到别的地方。但是玩了一会儿并没有产生预期的结果。
有人有什么建议吗?
更改此行
_centerViewController.view.frame = CGRectMake(self.view.frame.size.width - PANEL_WIDTH, 0, self.view.frame.size.width, self.view.frame.size.height);
到这一行
childView.frame = CGRectMake(PANEL_WIDTH, 0, childView.frame.size.width, childView.frame.size.height);
也不要sendsubViewToBack,改这一行
[self.view sendSubviewToBack:childView];
到这一行
[self.view bringSubViewToFront:childView];
我关注了 Tammy Coron this great tutorial。一切都很好,我明白它是如何工作的,但我想要实现的有点不同。我希望中央视图是“静态的”,可以这么说,侧面板与这个中央视图重叠。 所以我应该改变这部分:
UIView *childView = [self getLeftView];
[self.view sendSubviewToBack:childView];
[UIView animateWithDuration:SLIDE_TIMING delay:0 options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
_centerViewController.view.frame = CGRectMake(self.view.frame.size.width - PANEL_WIDTH, 0, self.view.frame.size.width, self.view.frame.size.height);
}
completion:^(BOOL finished) {
if (finished) {
_centerViewController.leftButton.tag = 0;
}
}];
到别的地方。但是玩了一会儿并没有产生预期的结果。 有人有什么建议吗?
更改此行
_centerViewController.view.frame = CGRectMake(self.view.frame.size.width - PANEL_WIDTH, 0, self.view.frame.size.width, self.view.frame.size.height);
到这一行
childView.frame = CGRectMake(PANEL_WIDTH, 0, childView.frame.size.width, childView.frame.size.height);
也不要sendsubViewToBack,改这一行
[self.view sendSubviewToBack:childView];
到这一行
[self.view bringSubViewToFront:childView];