• Stars
    star
    592
  • Rank 73,924 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This is a copy of the Prisma APP. Reproduce Prisma custom camera, image picker and picture editor

PrismaSimpleImagePicker

Logo

Custom camera, image picker ,image editor and the interface just like Prisma's style.

Overview

OverView1

OverView2

OverView3

Introduction

This is just a client function copy of Prisma, not a pod solution

Prisma is a sucessful APP of photo editing, but it's success is more than just art. And the details of the Prisma is also very good. So, I try to reproduce the client function of Prisma use Swift, and the result is this project.

This is build with Storyboard and xib, just because the Prisma is also used Storyboard and xib. The follow is the struct:

Struct

What is the use of this project?

Firstly, we can learn how to custom camera use framework AVFoundation.

  • AVCaptureSession A session to manage camera, responsible for the video image management function
  • AVCaptureDeviceInput Do the image acquisition
  • AVCaptureStillImageOutput Function for image stream output
  • AVCaptureVideoPreviewLayer Video preview layer, used to display the scene of the camera in real time

There is one thing we need to pay attention when we custom a camera, it's the image's orientation. Because the normal orientation of iPhone camera is lanscape left(Home button on the right), so the image orientation is different from our expected result. Below is a comparison.

Camera position

Secondly, from this project we can learn about some kowledge of system photo album. Because just support iOS8 above, so I use framework Photos to complete photo select, not the AssetsLibrary frmawork Prisma used. And below is the frameworks Prisma used.

Frameworks

Finally, we could just use the image picker in foder PrismaImagePicker, this is an independent function for developer jsut want to have a image picker with Prisma's syle.

More details, please view my blog(Only Chinese supported)

How to use PrismaImagePicker?

  • Create an object of class PMImagePickerController, and just present it from your own view controller.
  • If you just have the data source before, you can set the data source of PMImagePickerController, so it can be fast because without read the photo album.
  • Conform to protocol PMImagePickerControllerDelegate, and implement the delegate used.

The PMImagePickerControllerDelegate

@objc protocol PMImagePickerControllerDelegate: NSObjectProtocol {
    /**
     Call when tap `Use` button of the picker view controller
     
     - parameter picker: The view controller of class PMImagePickerController
     - parameter image:  An cropped image which displayed in the top header after edit
     */
    optional func imagePickerController(picker: PMImagePickerController, didFinishPickingImage image: UIImage)
    
    /**
     Call when tap `Use` button of the picker view controller
     
     - parameter picker:        The view controller of class PMImagePickerController
     - parameter originalImage: An original image which displayed in the top header
     - parameter selectedRect:  A rect displayed of the header
     - parameter zoomScale:     ZoomScale of the image
     */
    optional func imagePickerController(picker: PMImagePickerController, didFinishPickingImage originalImage: UIImage, selectedRect: CGRect, zoomScale:CGFloat)
    
    /**
     Call when tap `Cancel` button of the picker view controller
     
     - parameter picker: The view controller of class PMImagePickerController
     */
    optional func imagePickerControllerDidCancel(picker: PMImagePickerController)
}

Create and use the iamge picker
// Create image picker
@IBAction func selectPhoto(sender: AnyObject) {
    let nav = PMImagePickerController.init()
    nav.pmDelegate = self
    nav.photoGroups = photoGroups
    nav.photoAssets = photoAssets
    weak var weakSelf = self
    self.presentViewController(nav, animated: true) {
        weakSelf!.session.stopRunning()
    }
}


// PMImagePickerControllerDelegate
func imagePickerController(picker: PMImagePickerController, didFinishPickingImage originalImage: UIImage, selectedRect: CGRect, zoomScale:CGFloat) {
    // Do something with the original image
    ...
}
    
func imagePickerController(picker: PMImagePickerController, didFinishPickingImage image: UIImage) {
    // Dow something with the cropped image
    ...
}

func imagePickerControllerDidCancel(picker: PMImagePickerController) {
    session.startRunning()
}

Custom your own album kind

The default album is CameraFavoritesScreenShots and User photos, and all the operations of image is in PMImageManger.swift.

If you want change the kind of album, you could change the parameters PHAssetCollectionType and PHAssetCollectionSubtype in function class func photoLibrarys() -> [PHAssetCollection]

License

PrismaSimpleImagePicker is available under the MIT license. See the LICENSE file for more info.

More Repositories

1

SwipeTableView

Both scroll horizontal and vertical for segment scrollview which have a same header. — 类似半糖、美丽说主页与QQ音乐歌曲列表布局效果,实现不同菜单的左右滑动切换,同时支持类似tableview的顶部工具栏悬停(既可以左右滑动,又可以上下滑动)。兼容下拉刷新,自定义 collectionview实现自适应 contentSize 还可实现瀑布流功能
Objective-C
2,284
star
2

WYNews_ZhiXun

这个项目是初学iOS时模仿网易新闻写的,实现了视频音频等功能。框架结构视频播放等还有待优化
Objective-C
15
star
3

RLStickyHeaderFlowLayout

Swift language for CSStickyHeaderFlowLayout, UICollectionView replacement of UITableView. Do even more like Parallax Header, Sticky Section Header. ——— Swift版的CSStickyHeaderFlowLayout,使UICollectionView实现类似UITableView SectionHeader的悬停,并增加顶部ParallaxHeader,实现视差效果。
Swift
10
star
4

RLMenuController

模仿微信朋友圈点赞评论弹出菜单,提供四种方向的动画。暂时只做了部分的弹出自适应屏幕边缘,只支持文字标题,暂没有提供图片文字功能。
Objective-C
2
star
5

Interview

1
star
6

DoubleWeChat

Objective-C
1
star
7

RLParallaxView

网易云歌单头部过渡效果
Objective-C
1
star
8

JailDingTalk

Objective-C
1
star
9

RLFullScreenTransNavigationController

可以全屏滑动返回的导航栏,效果类似QQ音乐、网易新闻、头条新闻等的导航过渡效果。而且,支持指定返回页面,返回到指定的页面
Objective-C
1
star