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

DOM Scripting

DOM Scripting

Jeremy Keith / friendsofED / 2010-12 / GBP 27.50

There are three main technologies married together to create usable, standards-compliant web designs: XHTML for data structure, Cascading Style Sheets for styling your data, and JavaScript for adding ......一起来看看 《DOM Scripting》 这本书的介绍吧!

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具