Skip to content

mengkaka/TakePicture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TakePicture

自定义相机、图片裁剪

简介

一个集成自定义相机、图片裁剪、及其他相关功能的Demo,每个模块都按控件封装好,内有详细注视,低耦合,可直接拿出可用;

自定义相机拍照(K12CameraTakePictureView

1.继承自UIView,通过AVCaptureSession并且使用AVCaptureVideoPreviewLayer进行渲染;
2.一行代码检测用户相机权限;
3.方便控制摄像头闪光灯、和手电筒开启模式,还可以检测当前摄像头周边环境,太暗会以通知的方式发送出来;
4.自定义显示拍照参考线相机对焦样式焦距远近样式

使用方法

K12CameraTakePictureView *takePhotoView = [[K12CameraTakePictureView alloc]initWithFrame:self.view.bounds];
takePhotoView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:takePhotoView];

监听周围环境

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(cameraTakePhotoViewAmbientDidChange:) name:K12CameraTakePictureViewAmbientDidChangeNotification object:takePhotoView];

图片裁剪功能(K12PictureCuttingView

1.继承自UIView
2.可进行图片放大缩小、裁剪框放大缩小,裁剪图片的任意位置;
3.根据裁剪框和图片大小动态调整可滑动区域,可在任何时候都能够裁剪到图片的任何位置;

使用方法

K12PictureCuttingView *cropView = [[K12PictureCuttingView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height-90)];
[cropView setCuttingImage:_image];
[self.view addSubview:cropView];
cropView.backgroundColor = [UIColor colorWithRed:16/255.0*3.52 green:32/255.0*3.52 blue:42/255.0*3.52 alpha:1.0];
cropView.defultCorpInset = UIEdgeInsetsMake(0, 50, 0, 50);

其他

动态键盘输入框(K12TextInputManager

采用Autolayout动态根据文字长度布局输入框高度,超出固定行数以后自动向上滚动;

检测图片明暗度(K12ImageLuminance

利用Rx0.299+Gx0.587+Bx0.114计算出每个像素点的明暗度,在计算整张图片平均明暗度;

系统图片浏览查看(K12PhotoLibraryController

可查看系统图片列表,并且点击查看大图,并且点击确认按钮,返回图片;

图片方向矫正(UIImage+Orientation

可矫正或指定图片的方向

About

自定义相机、图片裁剪、自定义键盘

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published