添加HWPanModal和FLAnimatedImage

This commit is contained in:
2025-11-05 22:04:56 +08:00
parent efdcf60ed1
commit abf32e8457
97 changed files with 10853 additions and 2067 deletions

View File

@@ -0,0 +1,47 @@
//
// HWPanModalPresenterProtocol.h
// Pods
//
// Created by heath wang on 2019/4/29.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <HWPanModal/HWPanModalPresentable.h>
@class HWPanModalPresentationDelegate;
NS_ASSUME_NONNULL_BEGIN
@protocol HWPanModalPresenter <NSObject>
@property (nonatomic, assign, readonly) BOOL isPanModalPresented;
/**
* 这里我们将实现UIViewControllerTransitioningDelegate协议的delegate通过runtime存入到viewControllerToPresent中。
* use runtime to store this prop to hw_presentedVC
*/
@property (nonnull, nonatomic, strong) HWPanModalPresentationDelegate *hw_panModalPresentationDelegate;
/**
* Note: This method ONLY for iPad, like UIPopoverPresentationController.
*/
- (void)presentPanModal:(UIViewController<HWPanModalPresentable> *)viewControllerToPresent
sourceView:(nullable UIView *)sourceView
sourceRect:(CGRect)rect;
- (void)presentPanModal:(UIViewController<HWPanModalPresentable> *)viewControllerToPresent
sourceView:(nullable UIView *)sourceView
sourceRect:(CGRect)rect
completion:(void (^ __nullable)(void))completion;
/**
* Present the Controller from bottom.
*/
- (void)presentPanModal:(UIViewController<HWPanModalPresentable> *)viewControllerToPresent;
- (void)presentPanModal:(UIViewController<HWPanModalPresentable> *)viewControllerToPresent
completion:(void (^ __nullable)(void))completion;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,17 @@
//
// UIViewController+PanModalPresenter.h
// HWPanModal
//
// Created by heath wang on 2019/4/29.
//
#import <UIKit/UIKit.h>
#import "HWPanModalPresenterProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@interface UIViewController (PanModalPresenter) <HWPanModalPresenter>
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,64 @@
//
// UIViewController+PanModalPresenter.m
// HWPanModal
//
// Created by heath wang on 2019/4/29.
//
#import "UIViewController+PanModalPresenter.h"
#import "HWPanModalPresentationDelegate.h"
#import <objc/runtime.h>
@implementation UIViewController (PanModalPresenter)
- (BOOL)isPanModalPresented {
return [self.transitioningDelegate isKindOfClass:HWPanModalPresentationDelegate.class];
}
- (void)presentPanModal:(UIViewController<HWPanModalPresentable> *)viewControllerToPresent sourceView:(UIView *)sourceView sourceRect:(CGRect)rect completion:(void (^)(void))completion {
HWPanModalPresentationDelegate *delegate = [HWPanModalPresentationDelegate new];
viewControllerToPresent.hw_panModalPresentationDelegate = delegate;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad &&
(sourceView && !CGRectEqualToRect(rect, CGRectZero))) {
viewControllerToPresent.modalPresentationStyle = UIModalPresentationPopover;
viewControllerToPresent.popoverPresentationController.sourceRect = rect;
viewControllerToPresent.popoverPresentationController.sourceView = sourceView;
viewControllerToPresent.popoverPresentationController.delegate = delegate;
} else {
viewControllerToPresent.modalPresentationStyle = UIModalPresentationCustom;
viewControllerToPresent.modalPresentationCapturesStatusBarAppearance = YES;
viewControllerToPresent.transitioningDelegate = delegate;
}
// fix for iOS 8 issue: the present action will delay.
dispatch_async(dispatch_get_main_queue(), ^{
[self presentViewController:viewControllerToPresent animated:YES completion:completion];
});
}
- (void)presentPanModal:(UIViewController <HWPanModalPresentable> *)viewControllerToPresent sourceView:(nullable UIView *)sourceView sourceRect:(CGRect)rect {
[self presentPanModal:viewControllerToPresent sourceView:sourceView sourceRect:rect completion:nil];
}
- (void)presentPanModal:(UIViewController <HWPanModalPresentable> *)viewControllerToPresent {
[self presentPanModal:viewControllerToPresent sourceView:nil sourceRect:CGRectZero];
}
- (void)presentPanModal:(UIViewController<HWPanModalPresentable> *)viewControllerToPresent completion:(void (^)(void))completion {
[self presentPanModal:viewControllerToPresent sourceView:nil sourceRect:CGRectZero completion:completion];
}
- (HWPanModalPresentationDelegate *)hw_panModalPresentationDelegate {
return objc_getAssociatedObject(self, _cmd);
}
- (void)setHw_panModalPresentationDelegate:(HWPanModalPresentationDelegate *)hw_panModalPresentationDelegate {
objc_setAssociatedObject(self, @selector(hw_panModalPresentationDelegate), hw_panModalPresentationDelegate, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
@end