MaskingLayer 1.0.8

MaskingLayer 1.0.8

Maintained by daisukenagata.

  • By
  • daisukenagata


Version License Platform


To run the example project, clone the repo, and run pod install from the Example directory first. You can select background color, camera roll, video roll with long tap.

Example ViewController

import UIKit
import MaskingLayer

class ViewController: UIViewController {

    override func viewDidLoad() {

        let mO = MaskingLayerViewModel(minSegment: 15)
        let MV = MaskGestureViewModel(mO: mO, vc: self)
        MV.maskGestureView?.frame = view.frame
        view.addSubview(MV.maskGestureView ?? UIView())

        mO.frameResize(images: UIImage(named: "IMG_4011")!)

Version 0.4.2

You can generate a GIF image by pressing the leftmost image.


Version 0.5 Version 0.5.1

Os12 portrait camera with iphoneX or higher, masking images where people are reflections

Version 0.6.4

Press BackImage with a long tap and decide the background, then select portrait camera image

Version 0.6.5

Added a compositing function that can be saved to the terminal.

Version 0.8 ~

The left is the latest version. Perform a smooth crop.

Version 1.0.0 ~

1. Select hair dyeing with a long tap

2. Selfie with red button

3. Save the photo with the blue button

Screen operation
1. Up swipe is Display of slider bar
2. Long tap is Hide slider bar

Operation link


Example Code

import UIKit
import MaskingLayer

class CameraViewController: UIViewController {

    static func identifier() -> String { return String(describing: ViewController.self) }

    static func viewController() -> ViewController {

        let sb = UIStoryboard(name: "Camera", bundle: nil)
        let vc = sb.instantiateInitialViewController() as! ViewController
        return vc

    private var mVM              : MaskingLayerViewModel? = nil
    private var mBObject         : MaskButtonView? = nil
    private var d: UIView?

    override func viewDidLoad() {
        d = UIView(frame: CGRect(x: 0, y: 44, width: self.view.frame.width, height: self.view.frame.height - 188))
    override func viewDidAppear(_ animated: Bool) {

        mBObject?.cameraMatte.isHidden = false
        mBObject?.cameraRecord.isHidden = false
        mVM = MaskingLayerViewModel(vc: self)
        mBObject = MaskButtonView(frame: self.tabBarController?.tabBar.frame ?? CGRect())

        self.tabBarController?.tabBar.addSubview(mBObject?.cameraMatte ?? UIButton())
        self.tabBarController?.tabBar.addSubview(mBObject?.cameraRecord ?? UIButton())

        mBObject?.cameraMatte.addTarget(self, action: #selector(btAction), for: .touchUpInside)
        mBObject?.cameraRecord.addTarget(self, action: #selector(cameraAction), for: .touchUpInside)

        view.addSubview(d ?? UIView())
        mVM?.cmareraPreView(d ?? UIView())


    override func viewWillDisappear(_ animated: Bool) {

        mBObject?.cameraMatte.isHidden = true
        mBObject?.cameraRecord.isHidden = true
        mVM = nil

    // DyeHair Set
    @objc func btAction() { mVM?.btAction() }

    // Save photosAlbum
    @objc func cameraAction() { mVM?.cameraAction() }



MaskingLayer is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'MaskingLayer'


daisukenagata, [email protected]


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