Commit 6c169d93 authored by 汪洋's avatar 汪洋

导航栏可以单独控制

parent e374e207
...@@ -29,4 +29,4 @@ Carthage ...@@ -29,4 +29,4 @@ Carthage
# Note: if you ignore the Pods directory, make sure to uncomment # Note: if you ignore the Pods directory, make sure to uncomment
# `pod install` in .travis.yml # `pod install` in .travis.yml
# #
# Pods/ Pods/
...@@ -13,6 +13,12 @@ ...@@ -13,6 +13,12 @@
@interface WMBaseViewController : UIViewController <OCNavigatioinBarDelegate> @interface WMBaseViewController : UIViewController <OCNavigatioinBarDelegate>
@property (nonatomic, strong) OCNavigatioinBar *navigationBar; @property (nonatomic, strong) OCNavigatioinBar *navigationBar;
/**
默认值为NO,表示导航栏自动被WMBaseViewController管理,永远在所有的view最上方。
设置为YES时表示因为特殊需求,开发人员需要自己控制导航,并且需要在viewDidLoad中确定navigationBar的位置
*/
@property (nonatomic, assign) BOOL controlNavigationByYou;
/** /**
* @brief 因为controller会有initWithCoder,init,initWithNib三种方式,为了避免子类代码的疏忽导致父类自定义init内容没有覆盖到,所以统一使用initController方法。需要调用super * @brief 因为controller会有initWithCoder,init,initWithNib三种方式,为了避免子类代码的疏忽导致父类自定义init内容没有覆盖到,所以统一使用initController方法。需要调用super
*/ */
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
} }
- (void)initController{ - (void)initController{
self.controlNavigationByYou = NO;
// 在 initController 中初始化自定义导航栏有很大好处。至少可以保证视图被push之前就可以访问navigationBar,以配置title等属性 // 在 initController 中初始化自定义导航栏有很大好处。至少可以保证视图被push之前就可以访问navigationBar,以配置title等属性
[self customNavigationBar]; [self customNavigationBar];
} }
...@@ -64,7 +65,9 @@ ...@@ -64,7 +65,9 @@
[super viewDidLayoutSubviews]; [super viewDidLayoutSubviews];
// 保证即使在loading的时候,仍然可以后退 // 保证即使在loading的时候,仍然可以后退
[self.view bringSubviewToFront:self.navigationBar]; if (!self.controlNavigationByYou) {
[self.view bringSubviewToFront:self.navigationBar];
}
} }
- (void)didMoveToParentViewController:(UIViewController *)parent { - (void)didMoveToParentViewController:(UIViewController *)parent {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment