本文介绍了iOS:在ImageView上绘制矩形并调整边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

附加的链接。


Attached 1 is a screenshot from an app called GeniusScan where you can photograph any document and an adjustable rectangular grid shows on the imageview. You can easily adjust the borders of the grid with your fingers to select the portion of the image that you want to scan. It will be then transformed into the correct prospective.

1- How can I draw and interact with the grid on the imageview?

2- How can I return the corner points of the grid to my view controller.

Update: I found a wonderful class called BJImageCropper which allows to use fingers to ajust the borders, but only for a box like rectangle. Can anyone suggest how it can be updated to support shapes like in the GeniusScan app?

解决方案

Dude:

I created a demo that solves both questions:

1- How can I draw and interact with the grid on the imageview?

By Adding 4 views that will act as interactive control points by adding UIPanGestureRecognizer and then drawing the grid using CAShapeLayer on top of your view.

2- How can I return the corner points of the grid to my view controller.

You must keep references to the four control points of your grid.

Here's the link to my code.

这篇关于iOS:在ImageView上绘制矩形并调整边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 05:09