From 3e8437ae559487362fae3525beb79c534c213a51 Mon Sep 17 00:00:00 2001
From: 单军华
Date: Thu, 12 Jul 2018 13:44:34 +0800
Subject: [PATCH] bug修复和功能优化

---
 screendisplay/screendisplay/Classes/Base/BaseControllers/LMJNavUIBaseViewController.m |  209 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 209 insertions(+), 0 deletions(-)

diff --git a/screendisplay/screendisplay/Classes/Base/BaseControllers/LMJNavUIBaseViewController.m b/screendisplay/screendisplay/Classes/Base/BaseControllers/LMJNavUIBaseViewController.m
new file mode 100755
index 0000000..bcd93f9
--- /dev/null
+++ b/screendisplay/screendisplay/Classes/Base/BaseControllers/LMJNavUIBaseViewController.m
@@ -0,0 +1,209 @@
+//
+//  LMJBaseViewController.m
+//  PLMMPRJK
+//
+//  Created by NJHu on 2017/3/29.
+//  Copyright �� 2017��� GoMePrjk. All rights reserved.
+//
+
+#import "LMJNavUIBaseViewController.h"
+#import "LMJNavigationBar.h"
+#import <sys/utsname.h>
+
+@implementation LMJNavUIBaseViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+
+    TWWeak(self);
+    [self.navigationItem addObserverBlockForKeyPath:TWKeyPath(self.navigationItem, title) block:^(id  _Nonnull obj, id  _Nonnull oldVal, NSString  *_Nonnull newVal) {
+        if (newVal.length > 0 && ![newVal isEqualToString:oldVal]) {
+            weakself.title = newVal;
+        }
+    }];
+}
+
+
+#pragma mark - ������������
+- (void)viewWillAppear:(BOOL)animated
+{
+    [super viewWillAppear:animated];
+    
+}
+
+- (void)viewWillLayoutSubviews
+{
+    [super viewWillLayoutSubviews];
+}
+
+
+- (void)viewDidLayoutSubviews
+{
+    [super viewDidLayoutSubviews];
+    
+    self.lmj_navgationBar.lmj_width = self.view.lmj_width;
+    [self.view bringSubviewToFront:self.lmj_navgationBar];
+}
+
+- (void)viewDidAppear:(BOOL)animated
+{
+    [super viewDidAppear:animated];
+    
+    [UIApplication sharedApplication].statusBarStyle = [self navUIBaseViewControllerPreferStatusBarStyle:self];
+}
+
+- (void)dealloc {
+    [self.navigationItem removeObserverBlocksForKeyPath:TWKeyPath(self.navigationItem, title)];
+}
+
+
+#pragma mark - LMJNavUIBaseViewControllerDataSource
+- (BOOL)navUIBaseViewControllerIsNeedNavBar:(LMJNavUIBaseViewController *)navUIBaseViewController
+{
+    return YES;
+}
+
+
+- (UIStatusBarStyle)navUIBaseViewControllerPreferStatusBarStyle:(LMJNavUIBaseViewController *)navUIBaseViewController
+{
+    return UIStatusBarStyleDefault;
+}
+
+
+#pragma mark - DataSource
+/**������������*/
+- (NSMutableAttributedString*)lmjNavigationBarTitle:(LMJNavigationBar *)navigationBar
+{
+    return [self changeTitle:self.title ?: self.navigationItem.title changeColor:[UIColor blackColor]];
+}
+
+/** ������������ */
+//- (UIImage *)lmjNavigationBarBackgroundImage:(LMJNavigationBar *)navigationBar
+//{
+//
+//}
+
+/** ��������� */
+- (UIColor *)lmjNavigationBackgroundColor:(LMJNavigationBar *)navigationBar
+{
+    return [UIColor clearColor];
+}
+
+/** ������������������������ */
+//- (BOOL)lmjNavigationIsHideBottomLine:(LMJNavigationBar *)navigationBar
+//{
+//    return NO;
+//}
+
+/** ������������������ */
+- (CGFloat)lmjNavigationHeight:(LMJNavigationBar *)navigationBar
+{
+    return [UIApplication sharedApplication].statusBarFrame.size.height + 44.0;
+}
+
+
+/** ��������������������� view */
+//- (UIView *)lmjNavigationBarLeftView:(LMJNavigationBar *)navigationBar
+//{
+//
+//}
+/** ������������������ view */
+//- (UIView *)lmjNavigationBarRightView:(LMJNavigationBar *)navigationBar
+//{
+//
+//}
+/** ������������������ View */
+//- (UIView *)lmjNavigationBarTitleView:(LMJNavigationBar *)navigationBar
+//{
+//
+//}
+/** ������������������������ */
+//- (UIImage *)lmjNavigationBarLeftButtonImage:(UIButton *)leftButton navigationBar:(LMJNavigationBar *)navigationBar
+//{
+//
+//}
+/** ������������������������ */
+//- (UIImage *)lmjNavigationBarRightButtonImage:(UIButton *)rightButton navigationBar:(LMJNavigationBar *)navigationBar
+//{
+//
+//}
+
+
+
+#pragma mark - Delegate
+/** ������������������������ */
+-(void)leftButtonEvent:(UIButton *)sender navigationBar:(LMJNavigationBar *)navigationBar
+{
+    NSLog(@"%s", __func__);
+}
+/** ������������������������ */
+-(void)rightButtonEvent:(UIButton *)sender navigationBar:(LMJNavigationBar *)navigationBar
+{
+    NSLog(@"%s", __func__);
+}
+/** ��������������� label ��������������� */
+-(void)titleClickEvent:(UILabel *)sender navigationBar:(LMJNavigationBar *)navigationBar
+{
+    NSLog(@"%s", __func__);
+}
+
+
+#pragma mark ���������������
+
+- (void)setNavBarImg:(NSString *)imageName
+{
+    UIImage *image = [UIImage imageNamed:imageName];
+    [self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
+    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
+    
+    NSDictionary *attribute = @{
+                                NSForegroundColorAttributeName:[UIColor whiteColor],
+                                NSFontAttributeName:[UIFont systemFontOfSize:18]
+                                };
+    
+    [self.navigationController.navigationBar setTitleTextAttributes:attribute];
+}
+
+- (NSMutableAttributedString *)changeTitle:(NSString *)curTitle changeColor:(UIColor*) color
+{
+    NSMutableAttributedString *title = [[NSMutableAttributedString alloc] initWithString:curTitle ?: @""];
+    
+    [title addAttribute:NSForegroundColorAttributeName value:color range:NSMakeRange(0, title.length)];
+    
+    [title addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:17] range:NSMakeRange(0, title.length)];
+    
+    return title;
+}
+
+
+- (LMJNavigationBar *)lmj_navgationBar
+{
+    // ���������������������������������������
+    if(!_lmj_navgationBar && [self.parentViewController isKindOfClass:[UINavigationController class]] && [self navUIBaseViewControllerIsNeedNavBar:self])
+    {
+        LMJNavigationBar *navigationBar = [[LMJNavigationBar alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 0)];
+        [self.view addSubview:navigationBar];
+        navigationBar.dataSource = self;
+        navigationBar.lmjDelegate = self;
+        
+        _lmj_navgationBar = navigationBar;
+    }
+    return _lmj_navgationBar;
+}
+
+
+
+
+- (void)setTitle:(NSString *)title
+{
+    [super setTitle:title];
+    self.lmj_navgationBar.title = [self changeTitle:title changeColor:[UIColor blackColor]];
+}
+
+@end
+
+
+
+
+
+

--
Gitblit v1.8.0