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
4d359407
Commit
4d359407
authored
Mar 01, 2018
by
汪洋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
升级导航栏阴影
parent
7f75631e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
124 additions
and
20 deletions
+124
-20
Podfile.lock
Example/Podfile.lock
+2
-2
OCNavigationBar.h
GMBase/Classes/OCNavigationBar.h
+2
-2
OCNavigationBar.m
GMBase/Classes/OCNavigationBar.m
+4
-14
UIView+NavigationShadow.h
GMBase/Classes/UIView+NavigationShadow.h
+22
-0
UIView+NavigationShadow.m
GMBase/Classes/UIView+NavigationShadow.m
+82
-0
WMBaseListViewController.m
GMBase/Classes/WMBaseListViewController.m
+7
-1
WMBaseViewController.m
GMBase/Classes/WMBaseViewController.m
+5
-1
No files found.
Example/Podfile.lock
View file @
4d359407
...
...
@@ -14,7 +14,7 @@ PODS:
- AFNetworking/Serialization (3.1.0)
- AFNetworking/UIKit (3.1.0):
- AFNetworking/NSURLSession
- GMBase (0.3.
5
):
- GMBase (0.3.
6
):
- GMHud
- GMKit
- GMNetService
...
...
@@ -88,7 +88,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67
GMBase:
790ee33a3df893c09ea53d5ca9c7193ca86643e6
GMBase:
01b1716791f19442c6a3f7b675a22d69bb832a69
GMCache: fb0af70b420715ef9519487fdd932a357b3cd8d4
GMHud: 74387462a8b9f099c760a1ddbf493cc86da7cdbc
GMKit: 39ca9fdf84f75f4baad186585faef4dbef82f73b
...
...
GMBase/Classes/OCNavigationBar.h
View file @
4d359407
...
...
@@ -7,6 +7,7 @@
//
#import <UIKit/UIKit.h>
#import "UIView+NavigationShadow.h"
NS_ASSUME_NONNULL_BEGIN
@class
OCNavigationBarButton
;
...
...
@@ -52,8 +53,7 @@ NS_ASSUME_NONNULL_BEGIN
@property
(
nonatomic
,
copy
,
nullable
)
NSString
*
nearRightIconURL
;
@property
(
nonatomic
,
copy
,
nullable
)
NSString
*
rightIconURL
;
/// 默认显示阴影(严格来说是一条线,并不是阴影)
-
(
void
)
showShadow
:(
BOOL
)
show
;
-
(
void
)
hideAllItems
;
@end
...
...
GMBase/Classes/OCNavigationBar.m
View file @
4d359407
...
...
@@ -16,7 +16,7 @@
@end
@implementation
OCNavigationBar
{
UIView
*
_shadowView
;
}
-
(
instancetype
)
initWithFrame
:
(
CGRect
)
frame
...
...
@@ -34,16 +34,10 @@
}
-
(
void
)
setup
{
self
.
clipsToBounds
=
NO
;
self
.
backgroundColor
=
[
UIColor
whiteColor
];
_shadowView
=
[
UIView
new
];
_shadowView
.
backgroundColor
=
[
UIColor
colorWithhex
:
0xf0f0f0
];
[
self
addSubview
:
_shadowView
];
[
_shadowView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
bottom
.
mas_equalTo
(
0
);
make
.
left
.
mas_equalTo
(
0
);
make
.
right
.
mas_equalTo
(
0
);
make
.
height
.
offset
(
1
/
[
UIScreen
mainScreen
].
scale
);
}];
[
self
addNavigationShadow
];
_itemView
=
[[
UIView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
[
UIScreen
mainScreen
].
bounds
.
size
.
width
,
44
)];
CGFloat
titleW
=
[
UIScreen
mainScreen
].
bounds
.
size
.
width
-
80
;
_titleLabel
=
[[
UILabel
alloc
]
initWithFrame
:
CGRectMake
(
40
,
0
,
titleW
,
44
)];
...
...
@@ -119,10 +113,6 @@
}
#pragma mark - Public
-
(
void
)
showShadow
:
(
BOOL
)
show
{
_shadowView
.
hidden
=
!
show
;
}
-
(
void
)
hideAllItems
{
_titleLabel
.
hidden
=
YES
;
_leftButton
.
hidden
=
YES
;
...
...
GMBase/Classes/UIView+NavigationShadow.h
0 → 100644
View file @
4d359407
//
// UIView+NavigationShadow.h
// GMBase
//
// Created by wangyang on 2018/2/23.
//
#import <UIKit/UIKit.h>
@interface
UIView
(
NavigationShadow
)
/**
添加阴影,默认效果只在视图下方显示阴影。注意只适用于UI规范中的导航范围:导航栏下等。
*/
-
(
void
)
addNavigationShadow
;
/**
默认YES,是否显示阴影
*/
@property
(
nonatomic
,
assign
)
BOOL
isShowShadow
;
@end
GMBase/Classes/UIView+NavigationShadow.m
0 → 100644
View file @
4d359407
//
// UIView+NavigationShadow.m
// GMBase
//
// Created by wangyang on 2018/2/23.
//
#import "UIView+NavigationShadow.h"
@import
GMKit
;
#import <objc/runtime.h>
@interface
UIView
()
//@property (nonatomic, strong) UIView *shadowLayer;
@property
(
nonatomic
,
strong
)
CALayer
*
shadowLayer
;
@end
@implementation
UIView
(
NavigationShadow
)
-
(
void
)
addNavigationShadow
{
self
.
layer
.
masksToBounds
=
NO
;
// self.layer.shadowOpacity = 1.0f;
// self.layer.shadowRadius = 2.0f;
// self.layer.shadowOffset = CGSizeMake(0.0, ONE_PIXEL);
// self.isShowShadow = YES;
// self.hideTopShadow = YES;
// UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, self.bounds.size.height - 12, Constant.screenWidth, 12)];
// view.backgroundColor = [UIColor whiteColor];
// view.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
// [self addSubview:view];
// [self sendSubviewToBack:view];
// view.layer.masksToBounds = NO;
// view.layer.shadowOpacity = 1.0f;
// view.layer.shadowRadius = 2.0f;
// view.layer.shadowOffset = CGSizeMake(0.0, ONE_PIXEL);
// //view.isShowShadow = YES;
// view.layer.shadowColor = [UIColor colorWithWhite:0 alpha:0.1].CGColor;
self
.
shadowLayer
=
[
CALayer
layer
];
self
.
shadowLayer
.
bounds
=
CGRectMake
(
0
,
0
,
Constant
.
screenWidth
,
12
);
self
.
shadowLayer
.
position
=
CGPointMake
(
self
.
bounds
.
size
.
width
/
2
,
self
.
bounds
.
size
.
height
-
6
);
self
.
shadowLayer
.
backgroundColor
=
[
UIColor
whiteColor
].
CGColor
;
[
self
.
layer
insertSublayer
:
self
.
shadowLayer
atIndex
:
0
];
self
.
shadowLayer
.
masksToBounds
=
NO
;
self
.
shadowLayer
.
shadowOpacity
=
1
.
0
f
;
self
.
shadowLayer
.
shadowRadius
=
2
.
0
f
;
self
.
shadowLayer
.
shadowOffset
=
CGSizeMake
(
0
.
0
,
ONE_PIXEL
);
self
.
isShowShadow
=
YES
;
self
.
shadowLayer
.
shadowPath
=
CGPathCreateWithRect
(
CGRectMake
(
0
,
self
.
shadowLayer
.
bounds
.
size
.
height
-
6
,
Constant
.
screenWidth
,
6
),
nil
);
}
-
(
void
)
setIsShowShadow
:
(
BOOL
)
isShowShadow
{
objc_setAssociatedObject
(
self
,
@selector
(
isShowShadow
),
@
(
isShowShadow
),
OBJC_ASSOCIATION_RETAIN_NONATOMIC
);
if
(
isShowShadow
)
{
self
.
shadowLayer
.
shadowColor
=
[
UIColor
colorWithWhite
:
0
alpha
:
0
.
1
].
CGColor
;
}
else
{
self
.
shadowLayer
.
shadowColor
=
[
UIColor
clearColor
].
CGColor
;
[
self
.
shadowLayer
removeFromSuperlayer
];
}
}
-
(
BOOL
)
isShowShadow
{
NSNumber
*
_isShowShadow
=
objc_getAssociatedObject
(
self
,
@selector
(
isShowShadow
));
if
(
_isShowShadow
==
nil
)
{
return
0
;
}
else
{
return
[
_isShowShadow
boolValue
];
}
}
-
(
void
)
setShadowLayer
:
(
CALayer
*
)
shadowLayer
{
objc_setAssociatedObject
(
self
,
@selector
(
shadowLayer
),
shadowLayer
,
OBJC_ASSOCIATION_RETAIN_NONATOMIC
);
}
-
(
CALayer
*
)
shadowLayer
{
CALayer
*
_shadowLayer
=
objc_getAssociatedObject
(
self
,
@selector
(
shadowLayer
));
if
(
_shadowLayer
==
nil
)
{
return
[
CALayer
new
];
}
else
{
return
_shadowLayer
;
}
}
@end
GMBase/Classes/WMBaseListViewController.m
View file @
4d359407
...
...
@@ -59,7 +59,13 @@
[
_table
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
equalTo
(
self
.
view
.
mas_left
);
make
.
right
.
equalTo
(
self
.
view
.
mas_right
);
make
.
top
.
mas_equalTo
(
OCNavigationBar
.
barHeight
);
if
([
self
.
parentViewController
isKindOfClass
:[
UINavigationController
class
]])
{
make
.
top
.
mas_equalTo
(
OCNavigationBar
.
barHeight
);
}
else
{
make
.
top
.
mas_equalTo
(
0
);
}
// make.top.mas_equalTo(OCNavigationBar.barHeight);
make
.
bottom
.
mas_equalTo
(
0
);
}];
...
...
GMBase/Classes/WMBaseViewController.m
View file @
4d359407
...
...
@@ -72,7 +72,11 @@
[
_emptyView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
mas_equalTo
(
0
);
make
.
right
.
mas_equalTo
(
0
);
make
.
top
.
mas_equalTo
(
OCNavigationBar
.
statusBarHeight
);
if
([
self
.
parentViewController
isKindOfClass
:[
UINavigationController
class
]])
{
make
.
top
.
mas_equalTo
(
OCNavigationBar
.
statusBarHeight
);
}
else
{
make
.
top
.
mas_equalTo
(
0
);
}
make
.
bottom
.
mas_equalTo
(
0
);
}];
}
...
...
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