10

I have a simple UIImageView in my view, but I can't seem to find any feature in Apple's documentation to change the UV Coordinates of this UIImageView, to convey my idea to you, this GIF file should preview how changing 4 vertices coordinates can change how the image gets viewed on the final UIImageView.

I tried to find a solution online too (other than documentation) and found none.

Enter image description here

I use Swift.

DeyaEldeen
  • 10,847
  • 10
  • 42
  • 75
  • What are you trying to achieve? See [The XY Problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem) – jtbandes Mar 28 '16 at 23:02

1 Answers1

7

You can achieve that very animation using UIView.transform or CALayer.transform. You'll need basic geometry to convert UV coordinates to a CGAffineTransform or CATransform3D.

I made an assumption that affine transform would suffice because in your animation the transform is affine (parallel lines stay parallel). In that case, 3 vertices are free -- the 4th one is constrained by the other 3.

If you have 3 vertices, you can compute the affine transform matrix using: Affine transformation algorithm

To achieve the infinite repeat, use UIImageResizingMode.Tile.

Community
  • 1
  • 1
szym
  • 5,606
  • 28
  • 34