• 头像图片裁剪


    1.第三方 

    TZImagePickerController.h

    - (void)pushTZImagePickerController {
        //    if (self.maxCountTF.text.integerValue <= 0) {
        //        return;
        //    }
        TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:1 columnNumber:3 delegate:self pushPhotoPickerVc:YES];
        // imagePickerVc.navigationBar.translucent = NO;
        
    #pragma mark - 五类个性化设置,这些参数都可以不传,此时会走默认设置
        imagePickerVc.isSelectOriginalPhoto = YES;
        
        //    if (self.maxCountTF.text.integerValue > 1) {
        // 1.设置目前已经选中的图片数组
        //        imagePickerVc.selectedAssets = YES; // 目前已经选中的图片数组
        //    }
        imagePickerVc.allowTakePicture = YES; // 在内部显示拍照按钮
        imagePickerVc.allowTakeVideo = YES;   // 在内部显示拍视频按
        imagePickerVc.videoMaximumDuration = 10; // 视频最大拍摄时间
        [imagePickerVc setUiImagePickerControllerSettingBlock:^(UIImagePickerController *imagePickerController) {
            imagePickerController.videoQuality = UIImagePickerControllerQualityTypeHigh;
        }];
        
        // imagePickerVc.photoWidth = 1000;
        
        // 2. Set the appearance
        // 2. 在这里设置imagePickerVc的外观
        // imagePickerVc.navigationBar.barTintColor = [UIColor greenColor];
        // imagePickerVc.oKButtonTitleColorDisabled = [UIColor lightGrayColor];
        // imagePickerVc.oKButtonTitleColorNormal = [UIColor greenColor];
        // imagePickerVc.navigationBar.translucent = NO;
        imagePickerVc.iconThemeColor = [UIColor colorWithRed:31 / 255.0 green:185 / 255.0 blue:34 / 255.0 alpha:1.0];
        imagePickerVc.showPhotoCannotSelectLayer = YES;
        imagePickerVc.cannotSelectLayerColor = [[UIColor whiteColor] colorWithAlphaComponent:0.8];
        [imagePickerVc setPhotoPickerPageUIConfigBlock:^(UICollectionView *collectionView, UIView *bottomToolBar, UIButton *previewButton, UIButton *originalPhotoButton, UILabel *originalPhotoLabel, UIButton *doneButton, UIImageView *numberImageView, UILabel *numberLabel, UIView *divideLine) {
            [doneButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        }];
        /*
         [imagePickerVc setAssetCellDidSetModelBlock:^(TZAssetCell *cell, UIImageView *imageView, UIImageView *selectImageView, UILabel *indexLabel, UIView *bottomView, UILabel *timeLength, UIImageView *videoImgView) {
         cell.contentView.clipsToBounds = YES;
         cell.contentView.layer.cornerRadius = cell.contentView.tz_width * 0.5;
         }];
         */
        
        // 3. Set allow picking video & photo & originalPhoto or not
        // 3. 设置是否可以选择视频/图片/原图
        imagePickerVc.allowPickingVideo = NO;
        imagePickerVc.allowPickingImage = YES;
        imagePickerVc.allowPickingOriginalPhoto = YES;
        imagePickerVc.allowPickingGif = NO;
        imagePickerVc.allowPickingMultipleVideo = NO; // 是否可以多选视频
        
        // 4. 照片排列按修改时间升序
        imagePickerVc.sortAscendingByModificationDate = NO;
        
        //     imagePickerVc.minImagesCount = 3;
        // imagePickerVc.alwaysEnableDoneBtn = YES;
        
        // imagePickerVc.minPhotoWidthSelectable = 3000;
        // imagePickerVc.minPhotoHeightSelectable = 2000;
        
        /// 5. Single selection mode, valid when maxImagesCount = 1
        /// 5. 单选模式,maxImagesCount为1时才生效
        imagePickerVc.showSelectBtn = NO;
        imagePickerVc.allowCrop = YES;
        //    imagePickerVc.needCircleCrop = YES;
        // 设置竖屏下的裁剪尺寸
        NSInteger left = 30;
        NSInteger widthHeight = self.view.frame.size.width - 2 * left;
        NSInteger top = (self.view.frame.size.height - widthHeight) / 2;
        //    imagePickerVc.cropRect = CGRectMake(left, top, widthHeight, widthHeight);
        imagePickerVc.cropRect = CGRectMake(left, top, widthHeight, widthHeight);
        //imagePickerVc.allowPreview = NO;
        // Deprecated, Use statusBarStyle
        // imagePickerVc.isStatusBarDefault = NO;
        imagePickerVc.statusBarStyle = UIStatusBarStyleLightContent;
        
        // 设置是否显示图片序号
        imagePickerVc.showSelectedIndex = YES;
        
    #pragma mark - 到这里为止
        
        // You can get the photos by block, the same as by delegate.
        // 你可以通过block或者代理,来得到用户选择的照片.
        [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
            NSLog(@"");
            for (UIImage *img in photos) {
                self.image = img;
                
            }
            [self.tableView reloadData];
        }];
        
        [self presentViewController:imagePickerVc animated:YES completion:nil];
    }
  • 相关阅读:
    浏览器兼容性
    Php Ajax 跨域问题
    $.ajax()验证登录
    ajax基础知识总结
    Highcharts获取json数据展现饼图 (转)
    (CV学习笔记)梯度下降优化算法
    (CV学习笔记)Attention
    (数学建模)线性规划
    NumPy中文文档搬砖(划掉)学习笔记(1)
    微机原理作业1微机基础
  • 原文地址:https://www.cnblogs.com/dujiahong/p/9944663.html
Copyright © 2020-2023  润新知