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
b4774602
Commit
b4774602
authored
Mar 25, 2020
by
汪洋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化 present 动画
parent
8a33bb80
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
44 deletions
+29
-44
GMNavigationController.m
GMBase/Classes/GMNavigationController.m
+1
-1
GMPresentAnimation.m
GMBase/Classes/GMPresentAnimation.m
+28
-43
No files found.
GMBase/Classes/GMNavigationController.m
View file @
b4774602
...
...
@@ -38,7 +38,7 @@
animation
.
transitionType
=
operation
;
return
animation
;
}
return
nil
;
}
...
...
GMBase/Classes/GMPresentAnimation.m
View file @
b4774602
...
...
@@ -9,16 +9,14 @@
#import "GMPresentAnimation.h"
#import "UIViewController+PushType.h"
@interface
GMPresentAnimation
()
<
UIViewControllerAnimatedTransitioning
>
@property
(
nonatomic
,
assign
)
NSTimeInterval
duration
;
@property
(
nonatomic
,
assign
)
NSTimeInterval
duration
;
@end
@implementation
GMPresentAnimation
-
(
instancetype
)
init
{
// 默认 push 动画时间0.6
-
(
instancetype
)
init
{
// 默认 push 动画时间0.6
if
(
self
=
[
super
init
])
{
// self.duration = 0.6;
self
.
duration
=
0
.
6
;
self
.
duration
=
0
.
6
;
}
return
self
;
}
...
...
@@ -30,12 +28,11 @@
NSTimeInterval
duration
=
[
self
transitionDuration
:
transitionContext
];
CGRect
bound
=
[[
UIScreen
mainScreen
]
bounds
];
fromVC
.
view
.
hidden
=
YES
;
[[
transitionContext
containerView
]
addSubview
:
fromVC
.
snapshot
];
[[
transitionContext
containerView
]
addSubview
:
toVC
.
view
];
[[
toVC
.
navigationController
.
view
superview
]
insertSubview
:
fromVC
.
snapshot
belowSubview
:
toVC
.
navigationController
.
view
];
toVC
.
navigationController
.
view
.
layer
.
anchorPoint
=
CGPointMake
(
0
.
5
,
2
.
0
);
...
...
@@ -47,77 +44,65 @@
delay
:
0
usingSpringWithDamping
:
1
.
0
initialSpringVelocity
:
0
options
:
UIViewAnimationOptionCurve
Linear
options
:
UIViewAnimationOptionCurve
EaseInOut
animations
:^
{
fromVC
.
snapshot
.
transform
=
CGAffineTransformMakeTranslation
(
0
,
0
);
toVC
.
navigationController
.
view
.
transform
=
CGAffineTransformMakeTranslation
(
0
,
0
);
fromVC
.
snapshot
.
transform
=
CGAffineTransformMakeTranslation
(
0
,
0
);
toVC
.
navigationController
.
view
.
transform
=
CGAffineTransformMakeTranslation
(
0
,
0
);
}
completion
:^
(
BOOL
finished
)
{
fromVC
.
view
.
hidden
=
NO
;
[
fromVC
.
snapshot
removeFromSuperview
];
[
transitionContext
completeTransition
:
YES
];
fromVC
.
view
.
hidden
=
NO
;
[
transitionContext
completeTransition
:
YES
];
}];
}
-
(
void
)
pop
:
(
id
<
UIViewControllerContextTransitioning
>
)
transitionContext
{
-
(
void
)
pop
:
(
id
<
UIViewControllerContextTransitioning
>
)
transitionContext
{
UIViewController
*
fromVC
=
[
transitionContext
viewControllerForKey
:
UITransitionContextFromViewControllerKey
];
UIViewController
*
toVC
=
[
transitionContext
viewControllerForKey
:
UITransitionContextToViewControllerKey
];
NSTimeInterval
duration
=
[
self
transitionDuration
:
transitionContext
];
CGRect
bound
=
[[
UIScreen
mainScreen
]
bounds
];
[
fromVC
.
view
addSubview
:
fromVC
.
snapshot
];
fromVC
.
navigationController
.
navigationBar
.
hidden
=
YES
;
//
添加阴影
// 添加阴影
fromVC
.
snapshot
.
layer
.
shadowColor
=
[
UIColor
colorWithRed
:
0
.
2
green
:
0
.
2
blue
:
0
.
2
alpha
:
0
.
8
].
CGColor
;
fromVC
.
snapshot
.
layer
.
shadowOffset
=
CGSizeMake
(
-
3
,
0
);
fromVC
.
snapshot
.
layer
.
shadowOpacity
=
0
.
5
;
fromVC
.
view
.
layer
.
anchorPoint
=
CGPointMake
(
0
.
5
,
2
.
5
);
fromVC
.
view
.
frame
=
bound
;
toVC
.
view
.
hidden
=
YES
;
toVC
.
view
.
hidden
=
YES
;
[[
transitionContext
containerView
]
addSubview
:
toVC
.
view
];
[[
transitionContext
containerView
]
addSubview
:
toVC
.
snapshot
];
[[
transitionContext
containerView
]
sendSubviewToBack
:
toVC
.
snapshot
];
[
UIView
animateWithDuration
:
duration
delay
:
0
usingSpringWithDamping
:
1
.
0
initialSpringVelocity
:
0
options
:
UIViewAnimationOptionCurve
Linear
options
:
UIViewAnimationOptionCurve
EaseInOut
animations
:^
{
fromVC
.
view
.
transform
=
CGAffineTransformMakeTranslation
(
0
,
CGRectGetHeight
(
bound
));
toVC
.
snapshot
.
alpha
=
1
;
fromVC
.
view
.
transform
=
CGAffineTransformMakeTranslation
(
0
,
CGRectGetHeight
(
bound
));
toVC
.
snapshot
.
alpha
=
1
;
}
completion
:^
(
BOOL
finished
)
{
toVC
.
navigationController
.
navigationBar
.
hidden
=
NO
;
toVC
.
view
.
hidden
=
NO
;
[
fromVC
.
snapshot
removeFromSuperview
];
[
toVC
.
snapshot
removeFromSuperview
];
toVC
.
navigationController
.
navigationBar
.
hidden
=
NO
;
toVC
.
view
.
hidden
=
NO
;
if
(
!
[
transitionContext
transitionWasCancelled
])
{
toVC
.
snapshot
=
nil
;
}
[
transitionContext
completeTransition
:
!
[
transitionContext
transitionWasCancelled
]];
[
fromVC
.
snapshot
removeFromSuperview
];
[
toVC
.
snapshot
removeFromSuperview
];
if
(
!
[
transitionContext
transitionWasCancelled
])
{
toVC
.
snapshot
=
nil
;
}
[
transitionContext
completeTransition
:
!
[
transitionContext
transitionWasCancelled
]];
}];
}
-
(
NSTimeInterval
)
transitionDuration
:
(
nullable
id
<
UIViewControllerContextTransitioning
>
)
transitionContext
...
...
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