zac*_*ack 8 uinavigationcontroller ios
我有一个UINavigationController当事件被触发时我需要一个自定义UIView出现在它下方NavigationBar,但不会阻碍当前ViewController.我还需要在执行UIView控制器时弹出/推送持久性.
-----------------
| Status Bar |
-----------------
| Nav Bar |
-----------------
| Custom View |
-----------------
| |
| View Controller |
| |
-----------------
Run Code Online (Sandbox Code Playgroud)
我正在CustomView (UIView)设置框架,如:
- (id)initWithNavigationController:(UINavigationController *)navController {
self.navController = navController;
return [self init];
}
- (id)init
{
CGRect viewFrame = self.navController.view.frame;
return [self initWithFrame:CGRectMake(viewFrame.origin.x,
self.navController.navigationBar.frame.origin.y + self.navController.navigationBar.frame.size.height,
viewFrame.size.width,
40.0)];
}
Run Code Online (Sandbox Code Playgroud)
这是怎么回事?
- (id)initWithNavigationController:(UINavigationController *)navController {
CGRect viewFrame = navController.view.frame;
if (self = [super initWithFrame:CGRectMake(viewFrame.origin.x,
navController.navigationBar.frame.origin.y + navController.navigationBar.frame.size.height,
viewFrame.size.width,
40.0)]){
self.navController = navController;
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
然后
CustomView* _myCustomView = [[CustomView alloc] initWithNavigationController:navigationController];
[navigationcontroller.view addSubview:_myCustomView];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1777 次 |
| 最近记录: |