iOS 的自定义相机 SKFCamera

码农软件 · 软件分类 · 图像(Image) · 2019-05-29 14:14:49

软件介绍

开发iOS应用的过程中,很多情景都要调用相机,大多数初学开发者都是采用的苹果提供的系统相机的方法。

   UIImagePickerController *imagePickerController =  [[UIImagePickerController alloc] init];
   imagePickerController.delegate = self;
   imagePickerController.allowsEditing = YES;
   imagePickerController.sourceType = sourceType;
   [self presentViewController:imagePickerController animated:YES completion:^{}];

头文件要遵守协议方法,

       <UIImagePickerControllerDelegate, UINavigationControllerDelegate>

然后在下这个代理方法了里面获取拍照以后的照片。

//该代理方法仅适用于只选取图片时

   - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(nullable NSDictionary<NSString *,id> *)editingInfo
     { NSLog(@"选择完毕----image:%@-----info:%@",image,editingInfo);
    }

使用非常的不方便,而且调用系统的相机是不能自定义相机页面的,且如果从一个横屏页面进入系统的相机,就会崩溃报错。

因为在做一个自定义相机页面的时候,遇到了上面所说的坑,所以就有了下面这个demo,我写的这个相机,采用frame布局,可以随意自定义拍照页面,支持横屏,自定义裁剪。

git地址https://github.com/wubianxiaoxian/SKFCamera

调用方法简单,首先下载demo,将SKFCamera添加到工程,引入

#import "SKFCamera.h"

然后五行代码就可以引用这个相机了

  SKFCamera *homec=[[SKFCamera alloc]init];
  __weak typeof(self)myself=self;
  homec.fininshcapture=^(UIImage *ss){
    if (ss) {
        NSLog(@"照片存在");
      //在这里获取裁剪后的照片
        myself.ViewImageview.image=ss;
    }
} ;
    [self presentViewController:homec animated:NO completion:^{}];}

运行效果:

本文地址:https://www.codercto.com/soft/d/6805.html

We Are the Nerds

We Are the Nerds

Christine Lagorio-Chafkin / Hachette Books / 2018-10-2 / USD 18.30

Reddit hails itself as "the front page of the Internet." It's the third most-visited website in the United States--and yet, millions of Americans have no idea what it is. We Are the Nerds is an eng......一起来看看 《We Are the Nerds》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

URL 编码/解码
URL 编码/解码

URL 编码/解码