杨锴
2025-04-16 09a372bc45fde16fd42257ab6f78b8deeecf720b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
 * Tencent is pleased to support the open source community by making QMUI_iOS available.
 * Copyright (C) 2016-2021 THL A29 Limited, a Tencent company. All rights reserved.
 * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
 * http://opensource.org/licenses/MIT
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 */
 
//
//  QMUIImagePreviewViewTransitionAnimator.h
//  QMUIKit
//
//  Created by MoLice on 2018/D/19.
//
 
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "QMUIImagePreviewViewController.h"
 
NS_ASSUME_NONNULL_BEGIN
 
/**
 负责处理 QMUIImagePreviewViewController 被 present/dismiss 时的动画,如果需要自定义动画效果,可按需修改 animationEnteringBlock、animationBlock、animationCompletionBlock。
 @see QMUIImagePreviewViewController.transitioningAnimator
 */
@interface QMUIImagePreviewViewTransitionAnimator : NSObject<UIViewControllerAnimatedTransitioning>
 
/// 当前图片预览控件的引用,在为 QMUIImagePreviewViewController.transitioningAnimator 赋值时会自动建立这个引用关系
@property(nonatomic, weak) QMUIImagePreviewViewController *imagePreviewViewController;
 
/// 转场动画的持续时长,默认为 0.25
@property(nonatomic, assign) NSTimeInterval duration;
 
/// 当 sourceImageView 本身带圆角时,动画过程中会通过这个 layer 来处理圆角的动画
@property(nonatomic, strong, readonly) CALayer *cornerRadiusMaskLayer;
 
/**
 动画开始前的准备工作可以在这里做
 
 @param animator 当前的动画器 animator
 @param isPresenting YES 表示当前正在 present,NO 表示正在 dismiss
 @param style 当前动画的样式
 @param sourceImageRect 原界面上显示图片的 view 在 imagePreviewViewController.view 坐标系里的 rect,仅在 style 为 zoom 时有值,style 为 fade 时为 CGRectZero
 @param zoomImageView 当前图片
 @param transitionContext 转场动画的上下文,可通过它获取前后界面、动画容器等信息
 */
@property(nonatomic, copy) void (^animationEnteringBlock)(__kindof QMUIImagePreviewViewTransitionAnimator *animator, BOOL isPresenting, QMUIImagePreviewViewControllerTransitioningStyle style, CGRect sourceImageRect, QMUIZoomImageView *zoomImageView, id<UIViewControllerContextTransitioning> _Nullable transitionContext);
 
/**
 转场时的实际动画内容,整个 block 会在一个 UIView animation block 里被调用,因此直接写动画内容即可,无需包裹一个 animation block
 
 @param animator 当前的动画器 animator
 @param isPresenting YES 表示当前正在 present,NO 表示正在 dismiss
 @param style 当前动画的样式
 @param sourceImageRect 原界面上显示图片的 view 在 imagePreviewViewController.view 坐标系里的 rect,仅在 style 为 zoom 时有值,style 为 fade 时为 CGRectZero
 @param zoomImageView 当前图片
 @param transitionContext 转场动画的上下文,可通过它获取前后界面、动画容器等信息
 */
@property(nonatomic, copy) void (^animationBlock)(__kindof QMUIImagePreviewViewTransitionAnimator *animator, BOOL isPresenting, QMUIImagePreviewViewControllerTransitioningStyle style, CGRect sourceImageRect, QMUIZoomImageView *zoomImageView, id<UIViewControllerContextTransitioning> _Nullable transitionContext);
 
/**
 动画结束后的事情,在执行完这个 block 后才会调用 [transitionContext completeTransition:]
 
 @param animator 当前的动画器 animator
 @param isPresenting YES 表示当前正在 present,NO 表示正在 dismiss
 @param style 当前动画的样式
 @param sourceImageRect 原界面上显示图片的 view 在 imagePreviewViewController.view 坐标系里的 rect,仅在 style 为 zoom 时有值,style 为 fade 时为 CGRectZero
 @param zoomImageView 当前图片
 @param transitionContext 转场动画的上下文,可通过它获取前后界面、动画容器等信息
 */
@property(nonatomic, copy) void (^animationCompletionBlock)(__kindof QMUIImagePreviewViewTransitionAnimator *animator, BOOL isPresenting, QMUIImagePreviewViewControllerTransitioningStyle style, CGRect sourceImageRect, QMUIZoomImageView *zoomImageView, id<UIViewControllerContextTransitioning> _Nullable transitionContext);
 
@end
 
NS_ASSUME_NONNULL_END