guoyingtao / Mantis

An iOS Image cropping library, which mimics the Photo App written in Swift.
MIT License
907 stars 180 forks source link

Is it possible to hide the rotation dial? #311

Closed danielsaidi closed 1 year ago

danielsaidi commented 1 year ago

Hi! I'm building an OCR function in an app, using Mantis to crop the image.

It works great overall, but we find that the rotation dial often accidentally receives touch instead of the bottom crop handle, which leads to the image being rotated when you intended to crop from the bottom.

Is there any way to hide the rotation dial or move it further away from the crop handle?

guoyingtao commented 1 year ago

Hi @danielsaidi You can use Mantis.Config.cropViewConfig.showRotationDial to hide the rotation dial.

danielsaidi commented 1 year ago

Hi @guoyingtao

Thank you for pointing me in the right direction!

I actually tried it (seems like showRotationDial is deprecated and replaced by showAttachedRotationControlView) before posting...but it had no effect with this code:

let controller = Mantis.cropViewController(image: image)
controller.delegate = context.coordinator
controller.config.cropViewConfig.showAttachedRotationControlView = false

With this code, this was the result:

IMG_9C60857FC174-1

I looked at setupRotationControlViewIfNeeded and it seems like it should work, so I realized it's was probably due to that function being called at the time of controller creation.

And true enough, you need to setup the configuration before you create the controller:

var config = Mantis.Config()
config.cropViewConfig.showAttachedRotationControlView = false
let controller = Mantis.cropViewController(image: image, config: config)
controller.delegate = context.coordinator

This works great! However, I'm thinking that if you need to pass in the configuration and can't change it afterwards, perhaps the controller configuration should be immutable? Just a thought.

Thank you.

guoyingtao commented 1 year ago

@danielsaidi Thanks for the suggestion. Using var config make it easier to set multiple properties, also I can't prevent users to create var config