Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
GMBase
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
GMBase
Commits
0b1f46fd
Commit
0b1f46fd
authored
Nov 15, 2017
by
汪洋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iphonex适配
parent
f8081a03
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
37 deletions
+55
-37
GMBaseUtil.m
GMBase/Classes/GMBaseUtil.m
+0
-1
OCNavigationBar.h
GMBase/Classes/OCNavigationBar.h
+18
-13
OCNavigationBar.m
GMBase/Classes/OCNavigationBar.m
+27
-13
WMBaseListViewController.m
GMBase/Classes/WMBaseListViewController.m
+1
-1
WMBaseViewController.h
GMBase/Classes/WMBaseViewController.h
+3
-3
WMBaseViewController.m
GMBase/Classes/WMBaseViewController.m
+6
-6
No files found.
GMBase/Classes/GMBaseUtil.m
View file @
0b1f46fd
...
...
@@ -31,6 +31,5 @@
}
else
{
return
[[
MASViewAttribute
alloc
]
initWithView
:
self
layoutAttribute
:
NSLayoutAttributeBottom
];
}
}
@end
GMBase/Classes/OCNavigatio
i
nBar.h
→
GMBase/Classes/OCNavigationBar.h
View file @
0b1f46fd
//
// OCNavigatio
i
nBar.h
// OCNavigationBar.h
// Pods
//
// Created by wangyang on 16/7/8.
...
...
@@ -9,11 +9,11 @@
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class
OCNavigatio
i
nBarButton
;
@protocol
OCNavigatio
i
nBarDelegate
<
NSObject
>
-
(
void
)
rightButtonClicked
:
(
OCNavigatio
i
nBarButton
*
)
button
;
-
(
void
)
nearRightButtonClicked
:(
OCNavigatio
i
nBarButton
*
)
button
;
-
(
void
)
backAction
:(
OCNavigatio
i
nBarButton
*
)
button
;
@class
OCNavigationBarButton
;
@protocol
OCNavigationBarDelegate
<
NSObject
>
-
(
void
)
rightButtonClicked
:
(
OCNavigationBarButton
*
)
button
;
-
(
void
)
nearRightButtonClicked
:(
OCNavigationBarButton
*
)
button
;
-
(
void
)
backAction
:(
OCNavigationBarButton
*
)
button
;
@end
/**
...
...
@@ -21,9 +21,9 @@ NS_ASSUME_NONNULL_BEGIN
*
* 作为单独组件后,导航栏按键具体值应该由业务层控制。这里不再关心
*/
@interface
OCNavigatio
i
nBar
:
UIView
@property
(
nonatomic
,
weak
)
id
<
OCNavigatio
i
nBarDelegate
>
delegate
;
// OCNavigatio
i
nBar 高度是64,itemView的y坐标从20开始,高44。titleLabel,titleView,backButton,rightButton,nearRightButton都是被添加到该itemView中的
@interface
OCNavigationBar
:
UIView
@property
(
nonatomic
,
weak
)
id
<
OCNavigationBarDelegate
>
delegate
;
// OCNavigationBar 高度是64,itemView的y坐标从20开始,高44。titleLabel,titleView,backButton,rightButton,nearRightButton都是被添加到该itemView中的
@property
(
nonatomic
,
strong
,
readonly
)
UIView
*
itemView
;
@property
(
nonatomic
,
strong
,
readonly
)
UILabel
*
titleLabel
;
...
...
@@ -31,9 +31,9 @@ NS_ASSUME_NONNULL_BEGIN
@property
(
nonatomic
,
strong
,
nullable
)
UIView
*
titleView
;
@property
(
nonatomic
,
copy
,
nullable
)
NSString
*
title
;
@property
(
nonatomic
,
strong
,
readonly
)
OCNavigatio
i
nBarButton
*
leftButton
;
@property
(
nonatomic
,
strong
,
readonly
)
OCNavigatio
i
nBarButton
*
rightButton
;
@property
(
nonatomic
,
strong
,
readonly
)
OCNavigatio
i
nBarButton
*
nearRightButton
;
@property
(
nonatomic
,
strong
,
readonly
)
OCNavigationBarButton
*
leftButton
;
@property
(
nonatomic
,
strong
,
readonly
)
OCNavigationBarButton
*
rightButton
;
@property
(
nonatomic
,
strong
,
readonly
)
OCNavigationBarButton
*
nearRightButton
;
/**
leftIcon 有默认值:back
...
...
@@ -51,8 +51,13 @@ NS_ASSUME_NONNULL_BEGIN
-
(
void
)
hideAllItems
;
@end
@interface
OCNavigationBar
(
ViewConstant
)
@property
(
nonatomic
,
readonly
,
class
)
CGFloat
barHeight
;
@property
(
nonatomic
,
readonly
,
class
)
CGFloat
statusBarHeight
;
@property
(
nonatomic
,
readonly
,
class
)
CGFloat
navigationItemCenterY
;
@end
@interface
OCNavigatio
i
nBarButton
:
UIButton
@interface
OCNavigationBarButton
:
UIButton
@end
...
...
GMBase/Classes/OCNavigatio
i
nBar.m
→
GMBase/Classes/OCNavigationBar.m
View file @
0b1f46fd
//
// OCNavigatio
i
nBar.m
// OCNavigationBar.m
// Pods
//
// Created by wangyang on 16/7/8.
//
//
#import "OCNavigatio
i
nBar.h"
#import "OCNavigationBar.h"
#import <Masonry/Masonry.h>
#import "GMBaseUtil.h"
@import
GMKit
;
@interface
OCNavigatio
i
nBarButton
()
@interface
OCNavigationBarButton
()
@property
(
nonatomic
,
assign
)
CGFloat
adaptiveWidth
;
@end
@implementation
OCNavigatio
i
nBar
{
@implementation
OCNavigationBar
{
UIView
*
_shadowView
;
}
-
(
instancetype
)
initWithFrame
:
(
CGRect
)
frame
{
self
=
[
super
initWithFrame
:
frame
];
self
=
[
super
initWithFrame
:
CGRectMake
(
0
,
0
,
[
UIScreen
mainScreen
].
bounds
.
size
.
width
,
OCNavigationBar
.
barHeight
)
];
if
(
self
)
{
[
self
setup
];
}
...
...
@@ -53,9 +53,9 @@
_titleLabel
.
backgroundColor
=
[
UIColor
clearColor
];
_titleLabel
.
textColor
=
HEADLINE_TEXT_COLOR
;
_titleLabel
.
font
=
[
UIFont
navigationFontWithSize
:
18
];
_leftButton
=
[
OCNavigatio
i
nBarButton
buttonWithType
:
UIButtonTypeCustom
];
_rightButton
=
[
OCNavigatio
i
nBarButton
buttonWithType
:
UIButtonTypeCustom
];
_nearRightButton
=
[
OCNavigatio
i
nBarButton
buttonWithType
:
UIButtonTypeCustom
];
_leftButton
=
[
OCNavigationBarButton
buttonWithType
:
UIButtonTypeCustom
];
_rightButton
=
[
OCNavigationBarButton
buttonWithType
:
UIButtonTypeCustom
];
_nearRightButton
=
[
OCNavigationBarButton
buttonWithType
:
UIButtonTypeCustom
];
_titleLabel
.
hidden
=
YES
;
self
.
leftIcon
=
@"back"
;
...
...
@@ -87,7 +87,7 @@
}];
}
-
(
void
)
configBarButton
:
(
OCNavigatio
i
nBarButton
*
)
button
{
-
(
void
)
configBarButton
:
(
OCNavigationBarButton
*
)
button
{
UIColor
*
color
=
[
UIColor
colorWithhex
:
0x333333
];
[
button
setTitleColor
:
color
forState
:
UIControlStateNormal
];
button
.
hidden
=
YES
;
...
...
@@ -108,19 +108,19 @@
}
#pragma mark - Action
-
(
void
)
leftAction
:
(
OCNavigatio
i
nBarButton
*
)
button
{
-
(
void
)
leftAction
:
(
OCNavigationBarButton
*
)
button
{
if
([
self
.
delegate
respondsToSelector
:
@selector
(
backAction
:)])
{
[
self
.
delegate
backAction
:
button
];
}
}
-
(
void
)
rightAction
:
(
OCNavigatio
i
nBarButton
*
)
button
{
-
(
void
)
rightAction
:
(
OCNavigationBarButton
*
)
button
{
if
([
self
.
delegate
respondsToSelector
:
@selector
(
rightButtonClicked
:)])
{
[
self
.
delegate
rightButtonClicked
:
button
];
}
}
-
(
void
)
nearRightAction
:
(
OCNavigatio
i
nBarButton
*
)
button
{
-
(
void
)
nearRightAction
:
(
OCNavigationBarButton
*
)
button
{
if
([
self
.
delegate
respondsToSelector
:
@selector
(
nearRightButtonClicked
:)])
{
[
self
.
delegate
nearRightButtonClicked
:
button
];
}
...
...
@@ -181,10 +181,24 @@
[
_nearRightButton
setTitle
:
_nearRightTitle
forState
:
UIControlStateNormal
];
}
@end
@implementation
OCNavigationBar
(
ViewConstant
)
+
(
CGFloat
)
barHeight
{
return
[
self
statusBarHeight
]
+
44
;
}
+
(
CGFloat
)
statusBarHeight
{
return
[
UIApplication
sharedApplication
].
statusBarFrame
.
size
.
height
;
}
@implementation
OCNavigatioinBarButton
+
(
CGFloat
)
navigationItemCenterY
{
return
[
self
statusBarHeight
]
+
44
/
2
.
0
;
}
@end
@implementation
OCNavigationBarButton
/**
* @author wangyang in 2016-7-8 6.2.0
*
...
...
GMBase/Classes/WMBaseListViewController.m
View file @
0b1f46fd
...
...
@@ -58,7 +58,7 @@
[
_table
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
equalTo
(
self
.
view
.
mas_left
);
make
.
right
.
equalTo
(
self
.
view
.
mas_right
);
make
.
top
.
mas_equalTo
(
[
UIApplication
sharedApplication
].
statusBarFrame
.
size
.
height
+
44
);
make
.
top
.
mas_equalTo
(
OCNavigationBar
.
barHeight
);
make
.
bottom
.
equalTo
(
self
.
view
.
mas_safeBottom
);
}];
...
...
GMBase/Classes/WMBaseViewController.h
View file @
0b1f46fd
...
...
@@ -7,12 +7,12 @@
//
#import <UIKit/UIKit.h>
#import "OCNavigatio
i
nBar.h"
#import "OCNavigationBar.h"
#import <GMPhobos/GMPhobos-umbrella.h>
@import
GMKit
;
@interface
WMBaseViewController
:
UIViewController
<
OCNavigatio
i
nBarDelegate
,
GMEmptyViewDelegate
>
@property
(
nonatomic
,
strong
)
OCNavigatio
i
nBar
*
navigationBar
;
@interface
WMBaseViewController
:
UIViewController
<
OCNavigationBarDelegate
,
GMEmptyViewDelegate
>
@property
(
nonatomic
,
strong
)
OCNavigationBar
*
navigationBar
;
/**
默认值为NO,表示导航栏自动被WMBaseViewController管理,永远在所有的view最上方。
设置为YES时表示因为特殊需求,开发人员需要自己控制导航,并且需要在viewDidLoad中确定navigationBar的位置
...
...
GMBase/Classes/WMBaseViewController.m
View file @
0b1f46fd
...
...
@@ -72,7 +72,7 @@
[
_emptyView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
mas_equalTo
(
0
);
make
.
right
.
mas_equalTo
(
0
);
make
.
top
.
mas_equalTo
(
[
UIApplication
sharedApplication
].
statusBarFrame
.
size
.
h
eight
);
make
.
top
.
mas_equalTo
(
OCNavigationBar
.
statusBarH
eight
);
make
.
bottom
.
mas_equalTo
(
0
);
}];
}
...
...
@@ -116,7 +116,7 @@
#pragma mark - 导航
-
(
void
)
customNavigationBar
{
_navigationBar
=
[
[
OCNavigatioinBar
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
[
UIScreen
mainScreen
].
bounds
.
size
.
width
,
[
UIApplication
sharedApplication
].
statusBarFrame
.
size
.
height
+
44
)
];
_navigationBar
=
[
OCNavigationBar
new
];
}
-
(
void
)
addNavigationBar
{
...
...
@@ -139,10 +139,10 @@
[
self
.
navigationController
pushViewController
:
controller
animated
:
YES
];
}
#pragma mark - OCNavigatio
i
nBarDelegate
-
(
void
)
nearRightButtonClicked
:
(
OCNavigatio
i
nBarButton
*
)
button
{}
-
(
void
)
rightButtonClicked
:
(
OCNavigatio
i
nBarButton
*
)
button
{}
-
(
void
)
backAction
:
(
OCNavigatio
i
nBarButton
*
)
button
{
#pragma mark - OCNavigationBarDelegate
-
(
void
)
nearRightButtonClicked
:
(
OCNavigationBarButton
*
)
button
{}
-
(
void
)
rightButtonClicked
:
(
OCNavigationBarButton
*
)
button
{}
-
(
void
)
backAction
:
(
OCNavigationBarButton
*
)
button
{
if
([
self
.
parentViewController
isKindOfClass
:[
UINavigationController
class
]])
{
UINavigationController
*
navigation
=
(
UINavigationController
*
)
self
.
parentViewController
;
NSArray
*
controllers
=
navigation
.
viewControllers
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment