大佬教程收集整理的这篇文章主要介绍了ios – 如何使用导航控制器创建静态子视图?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
您可以通过创建一个包含UINavigationController的自定义UIViewController来实现此目的.创建一个名为“CustomViewController”的新类,并粘贴以下代码:
接口
#import <UIKit/UIKit.h> @interface CustomViewController : UIViewController - (id)initWithViewController:(UIViewController*)viewController bottomView:(UIView*)bottomView; @end
执行:
#import "CustomViewController.h" @implementation CustomViewController - (id)initWithViewController:(UIViewController*)viewController bottomView:(UIView*)bottomView { self = [super init]; if (self) { // Set up view size for navigationController; use full bounds minus 60pt at the bottom CGRect navigationControllerFrame = self.view.bounds; navigationControllerFrame.size.height -= 60; viewController.view.frame = navigationControllerFrame; // Set up view size for bottomView CGRect bottomViewFrame = CGRectMake(0,self.view.bounds.size.height-60,self.view.bounds.size.width,60); bottomView.frame = bottomViewFrame; // Enable autoresizing for both the navigationController @R_618_6296@e bottomView viewController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; bottomView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; // Add views as subviews to the current view [self.view addSubview:viewController.view]; [self.view addSubview:bottomView]; } return self; } @end
现在使用CustomViewController:
UIView *myBottomView = [[UIView alloc] initWithFrame:CGRectMake(0,200,100)]; myBottomView.BACkgroundColor = [UIColor redColor]; CustomViewController *customViewController = [[CustomViewController alloc] initWithViewController:<yourNavigationController> bottomView:myView];
以上是大佬教程为你收集整理的ios – 如何使用导航控制器创建静态子视图?全部内容,希望文章能够帮你解决ios – 如何使用导航控制器创建静态子视图?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。