iOS: Drawing a Rectangle on an ImageView and Adjusting Borders

前端 未结 2 410
天命终不由人
天命终不由人 2021-01-06 13:16

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 adju

2条回答
  •  失恋的感觉
    2021-01-06 13:44

    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.

提交回复
热议问题