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
0e5b5ae4
Commit
0e5b5ae4
authored
Feb 05, 2018
by
汪洋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
root view controller不支持旋转;可以通过h5为导航栏设置right button
parent
85c3ac62
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
1 deletion
+54
-1
GMNavigationController.m
GMBase/Classes/GMNavigationController.m
+13
-0
OCNavigationBar.h
GMBase/Classes/OCNavigationBar.h
+6
-0
OCNavigationBar.m
GMBase/Classes/OCNavigationBar.m
+30
-0
WMBaseViewController.m
GMBase/Classes/WMBaseViewController.m
+5
-1
No files found.
GMBase/Classes/GMNavigationController.m
View file @
0e5b5ae4
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#import "UIViewController+PushType.h"
#import "UIViewController+PushType.h"
#import "GMPresentAnimation.h"
#import "GMPresentAnimation.h"
@import
GMKit
;
@import
GMKit
;
@interface
GMNavigationController
()
<
UINavigationControllerDelegate
>
@interface
GMNavigationController
()
<
UINavigationControllerDelegate
>
@end
@end
...
@@ -41,4 +42,16 @@
...
@@ -41,4 +42,16 @@
return
nil
;
return
nil
;
}
}
// 依据supportedInterfaceOrientations文档,控制旋转的代码需要写在root view controller,或者全屏的presenting controller
// app的root view controller就是这个GMNavigationController,所以相关控制代码在这里。
-
(
BOOL
)
shouldAutorotate
{
return
NO
;
}
-
(
UIInterfaceOrientationMask
)
supportedInterfaceOrientations
{
return
UIInterfaceOrientationMaskPortrait
;
}
@end
@end
GMBase/Classes/OCNavigationBar.h
View file @
0e5b5ae4
...
@@ -46,6 +46,12 @@ NS_ASSUME_NONNULL_BEGIN
...
@@ -46,6 +46,12 @@ NS_ASSUME_NONNULL_BEGIN
@property
(
nonatomic
,
copy
,
nullable
)
NSString
*
rightTitle
;
@property
(
nonatomic
,
copy
,
nullable
)
NSString
*
rightTitle
;
@property
(
nonatomic
,
copy
,
nullable
)
NSString
*
nearRightTitle
;
@property
(
nonatomic
,
copy
,
nullable
)
NSString
*
nearRightTitle
;
/**
由h5 pagedata中传递过来的right_button
*/
@property
(
nonatomic
,
copy
,
nullable
)
NSString
*
nearRightIconURL
;
@property
(
nonatomic
,
copy
,
nullable
)
NSString
*
rightIconURL
;
/// 默认显示阴影(严格来说是一条线,并不是阴影)
/// 默认显示阴影(严格来说是一条线,并不是阴影)
-
(
void
)
showShadow
:(
BOOL
)
show
;
-
(
void
)
showShadow
:(
BOOL
)
show
;
-
(
void
)
hideAllItems
;
-
(
void
)
hideAllItems
;
...
...
GMBase/Classes/OCNavigationBar.m
View file @
0e5b5ae4
...
@@ -45,6 +45,7 @@
...
@@ -45,6 +45,7 @@
make
.
height
.
offset
(
1
/
[
UIScreen
mainScreen
].
scale
);
make
.
height
.
offset
(
1
/
[
UIScreen
mainScreen
].
scale
);
}];
}];
_itemView
=
[[
UIView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
[
UIApplication
sharedApplication
].
statusBarFrame
.
size
.
height
,
[
UIScreen
mainScreen
].
bounds
.
size
.
width
,
44
)];
_itemView
=
[[
UIView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
[
UIApplication
sharedApplication
].
statusBarFrame
.
size
.
height
,
[
UIScreen
mainScreen
].
bounds
.
size
.
width
,
44
)];
_itemView
.
autoresizingMask
=
UIViewAutoresizingFlexibleWidth
;
CGFloat
titleW
=
[
UIScreen
mainScreen
].
bounds
.
size
.
width
-
80
;
CGFloat
titleW
=
[
UIScreen
mainScreen
].
bounds
.
size
.
width
-
80
;
_titleLabel
=
[[
UILabel
alloc
]
initWithFrame
:
CGRectMake
(
40
,
0
,
titleW
,
44
)];
_titleLabel
=
[[
UILabel
alloc
]
initWithFrame
:
CGRectMake
(
40
,
0
,
titleW
,
44
)];
_titleLabel
.
lineBreakMode
=
NSLineBreakByTruncatingTail
;
_titleLabel
.
lineBreakMode
=
NSLineBreakByTruncatingTail
;
...
@@ -203,6 +204,35 @@
...
@@ -203,6 +204,35 @@
[
_nearRightButton
setTitle
:
_nearRightTitle
forState
:
UIControlStateNormal
];
[
_nearRightButton
setTitle
:
_nearRightTitle
forState
:
UIControlStateNormal
];
[
self
layoutTitle
];
[
self
layoutTitle
];
}
}
-
(
void
)
setNearRightIconURL
:
(
NSString
*
)
nearRightIconURL
{
_nearRightIconURL
=
nearRightIconURL
;
_nearRightButton
.
hidden
=
NO
;
[[
SDWebImageManager
sharedManager
]
downloadImageWithURL
:[
NSURL
URLWithString
:
_nearRightIconURL
]
options
:
0
progress
:
nil
completed
:^
(
UIImage
*
image
,
NSError
*
error
,
SDImageCacheType
cacheType
,
BOOL
finished
,
NSURL
*
imageURL
)
{
if
(
image
)
{
NSData
*
imageData
=
UIImagePNGRepresentation
(
image
);
UIImage
*
scaledImage
=
[
UIImage
imageWithData
:
imageData
scale
:[
UIScreen
mainScreen
].
scale
];
[
_nearRightButton
setImage
:
scaledImage
forState
:
UIControlStateNormal
];
}
}];
[
self
layoutTitle
];
}
-
(
void
)
setRightIconURL
:
(
NSString
*
)
rightIconURL
{
_rightIconURL
=
rightIconURL
;
_rightButton
.
hidden
=
NO
;
[[
SDWebImageManager
sharedManager
]
downloadImageWithURL
:[
NSURL
URLWithString
:
rightIconURL
]
options
:
0
progress
:
nil
completed
:^
(
UIImage
*
image
,
NSError
*
error
,
SDImageCacheType
cacheType
,
BOOL
finished
,
NSURL
*
imageURL
)
{
if
(
image
)
{
NSData
*
imageData
=
UIImagePNGRepresentation
(
image
);
UIImage
*
scaledImage
=
[
UIImage
imageWithData
:
imageData
scale
:[
UIScreen
mainScreen
].
scale
];
[
_rightButton
setImage
:
scaledImage
forState
:
UIControlStateNormal
];
}
}];
[
self
layoutTitle
];
}
@end
@end
@implementation
OCNavigationBar
(
ViewConstant
)
@implementation
OCNavigationBar
(
ViewConstant
)
...
...
GMBase/Classes/WMBaseViewController.m
View file @
0e5b5ae4
...
@@ -122,6 +122,11 @@
...
@@ -122,6 +122,11 @@
-
(
void
)
addNavigationBar
{
-
(
void
)
addNavigationBar
{
_navigationBar
.
delegate
=
self
;
_navigationBar
.
delegate
=
self
;
[
self
.
view
addSubview
:
_navigationBar
];
[
self
.
view
addSubview
:
_navigationBar
];
[
_navigationBar
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
top
.
mas_equalTo
(
0
);
make
.
left
.
right
.
mas_equalTo
(
0
);
make
.
height
.
mas_equalTo
(
OCNavigationBar
.
barHeight
);
}];
}
}
-
(
void
)
hideLeftButtonForRootController
{
-
(
void
)
hideLeftButtonForRootController
{
...
@@ -168,5 +173,4 @@
...
@@ -168,5 +173,4 @@
}
}
-
(
void
)
emptyViewDidClickReload
{}
-
(
void
)
emptyViewDidClickReload
{}
@end
@end
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