This repository was archived by the owner on Aug 30, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,10 @@ - (void)viewDidLoad {
60
60
61
61
@implementation FadeTransition
62
62
63
+ - (NSTimeInterval )transitionDurationWithContext : (nonnull id <MDMTransitionContext>)context {
64
+ return 0.3 ;
65
+ }
66
+
63
67
- (void )startWithContext : (id <MDMTransitionContext>)context {
64
68
[CATransaction begin ];
65
69
[CATransaction setCompletionBlock: ^{
Original file line number Diff line number Diff line change @@ -36,6 +36,17 @@ NS_SWIFT_NAME(Transition)
36
36
37
37
@end
38
38
39
+ /* *
40
+ A transition with custom duration is able to override the default transition duration.
41
+ */
42
+ NS_SWIFT_NAME (TransitionWithCustomDuration)
43
+ @protocol MDMTransitionWithCustomDuration
44
+ /* *
45
+ The desired duration of this transition in seconds.
46
+ */
47
+ - (NSTimeInterval )transitionDurationWithContext:(nonnull id <MDMTransitionContext>)context;
48
+ @end
49
+
39
50
/* *
40
51
A transition with presentation is able to customize the overall presentation of the transition,
41
52
including adding temporary views and changing the destination frame of the presented view
Original file line number Diff line number Diff line change @@ -50,8 +50,10 @@ - (nonnull instancetype)initWithTransition:(nonnull id<MDMTransition>)transition
50
50
#pragma mark - UIViewControllerAnimatedTransitioning
51
51
52
52
- (NSTimeInterval )transitionDuration : (id <UIViewControllerContextTransitioning>)transitionContext {
53
- // TODO(featherless): Expose a TransitionWithTiming protocol that allows the transition to
54
- // customize this value.
53
+ if ([_transition respondsToSelector: @selector (transitionDurationWithContext: )]) {
54
+ id <MDMTransitionWithCustomDuration> withCustomDuration = (id <MDMTransitionWithCustomDuration>)_transition;
55
+ return [withCustomDuration transitionDurationWithContext: self ];
56
+ }
55
57
return 0.35 ;
56
58
}
57
59
You can’t perform that action at this time.
0 commit comments