我正在尝试制作一个带有导航栏(返回按钮、标题等)和选项卡栏(底部的工具栏)的应用程序。我正在使用子视图,因此不必担心状态栏、导航栏、选项卡栏的高度等问题。但我认为这给我带来了麻烦,因为我似乎无法弄清如何设置导航栏和选项卡栏。
这是我的代码,我做错了什么?
AppDelegate.h:
(default for single view app)
AppDelegate.m
(default for single view app)
ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (strong, nonatomic) UIView *contentSubview;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)loadView{}
- (void)viewDidLoad
{
[super viewDidLoad];
UIView *view = [[UIView alloc] init];
view.backgroundColor = [UIColor greenColor];
self.contentSubview = [[UIView alloc] init];
self.contentSubview.backgroundColor = [UIColor orangeColor];
[view addSubview:self.contentSubview];
self.view = view;
}
- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
self.contentSubview.frame = CGRectMake(
0,
self.topLayoutGuide.length,
CGRectGetWidth(self.view.frame),
CGRectGetHeight(self.view.frame)-self.topLayoutGuide.length-self.bottomLayoutGuide.length
);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end