Tocropviewcontroller: How to create original done button

Created on 27 Jul 2019  ·  4Comments  ·  Source: TimOliver/TOCropViewController

question

Most helpful comment

@twinkalGSensussoft
Hi, Sample code is here.

  1. Create original cropViewController.
let cropViewController = CropViewController(image: OriginalImage)
  1. Add cropViewController to Container View
self.addChild(cropViewController)
self.cropContainer.addSubview(cropViewController.view)
  1. Adjust cropViewController frame.
cropViewController.view.frame = CGRect(x: self.cropContainer.frame.origin.x, y: self.cropContainer.frame.origin.y, width: self.cropContainer.frame.width, height: self.cropContainer.frame.height)
  1. If you want to hide default toolbar, you must below code.
cropViewController.toolbar.isHidden = true
  1. Display cropViewController.
cropViewController.didMove(toParent: self)
  1. Define original done action and call doneButtonTapped!().
@IBAction func cropDoneButtonTUP(_ sender: UIButton) {       
      self.cropViewController.toolbar.doneButtonTapped!()
}

All 4 comments

I have solved the problem myself.

How you have done this? Can you please give an explanation here? @ muranobu

@twinkalGSensussoft
Hi, Sample code is here.

  1. Create original cropViewController.
let cropViewController = CropViewController(image: OriginalImage)
  1. Add cropViewController to Container View
self.addChild(cropViewController)
self.cropContainer.addSubview(cropViewController.view)
  1. Adjust cropViewController frame.
cropViewController.view.frame = CGRect(x: self.cropContainer.frame.origin.x, y: self.cropContainer.frame.origin.y, width: self.cropContainer.frame.width, height: self.cropContainer.frame.height)
  1. If you want to hide default toolbar, you must below code.
cropViewController.toolbar.isHidden = true
  1. Display cropViewController.
cropViewController.didMove(toParent: self)
  1. Define original done action and call doneButtonTapped!().
@IBAction func cropDoneButtonTUP(_ sender: UIButton) {       
      self.cropViewController.toolbar.doneButtonTapped!()
}

What if I don't want only 90-degree rotation?. I want to add a rotation gesture to it, is it possible? If yes then please help me out.
thanks in advance.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asadqazi picture asadqazi  ·  3Comments

felipebonezi picture felipebonezi  ·  6Comments

TimOliver picture TimOliver  ·  4Comments

kcankaynak picture kcankaynak  ·  4Comments

dddOO7 picture dddOO7  ·  5Comments