1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- //
- // UIViewController+TZImagePickerController.m
- // Extension
- //
- // Created by CY on 2022/8/24.
- //
- #import "UIViewController+TZImagePickerController.h"
- @implementation UIViewController (TZImagePickerController)
- - (void)showImagePickerWithStyleBlock:(void (^)(TZImagePickerController * _Nonnull))styleBlock finishBlock:(nonnull void (^)(NSArray<UIImage *> * _Nonnull, NSArray * _Nonnull, BOOL))finishBlock{
- TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:6 delegate:self];
- if (styleBlock != nil) {
- styleBlock(imagePickerVc);
- }
- imagePickerVc.allowPickingVideo = NO;
- [imagePickerVc setDidFinishPickingPhotosHandle:finishBlock];
- imagePickerVc.cropViewSettingBlock = ^(UIView *cropView) { // < 自定义裁剪框的其他属性
- [cropView.superview setBackgroundColor:[UIColor colorWithWhite:0 alpha:0.9]];
- NSLog(@"asdasdad");
- };
- imagePickerVc.modalPresentationStyle = UIModalPresentationFullScreen;
- [self presentViewController:imagePickerVc animated:YES completion:nil];
- }
- - (void)showVideoPickerWithStyleBlock:(void (^)(TZImagePickerController * _Nonnull))styleBlock finishBlock:(nonnull void (^)(UIImage * _Nonnull coverImage, NSString * _Nonnull outputPath, NSString * _Nonnull errorMsg))finishBlock{
- TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:self];
- if (styleBlock != nil) {
- styleBlock(imagePickerVc);
- }
- imagePickerVc.maxCropVideoDuration = 60;
- imagePickerVc.videoMaximumDuration = 60;
- imagePickerVc.presetName = AVAssetExportPresetHighestQuality; //高清
- imagePickerVc.allowEditVideo = YES;
- // imagePickerVc.didFinishPickingAndEditingVideoHandle = ^(UIImage *coverImage, NSString *outputPath, NSString *errorMsg) {
- // NSLog(@"视频完成");
- // };
- [imagePickerVc setDidFinishPickingAndEditingVideoHandle:finishBlock];
- imagePickerVc.modalPresentationStyle = UIModalPresentationFullScreen;
- [self presentViewController:imagePickerVc animated:YES completion:nil];
- }
- @end
|