UIImageView是否有任何UV坐标(或类似)?

时间:2021-01-27 21:19:16

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.

我在视图中有一个简单的UIImageView,但我似乎无法在Apple的文档中找到任何更改此UIImageView的UV坐标的功能,以便向我传达我的想法,此GIF文件应预览更改4个顶点坐标的更改方式如何在最终的UIImageView上查看图像。

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

我试图在网上找到一个解决方案(除了文档),但没有找到。

UIImageView是否有任何UV坐标(或类似)?

I use Swift.

我用Swift。

1 个解决方案

#1


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.

您可以使用UIView.transform或CALayer.transform实现该动画。您需要基本几何体将UV坐标转换为CGAffineTransform或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.

我假设仿射变换就足够了,因为在动画中变换是仿射的(平行线保持平行)。在这种情况下,3个顶点是*的 - 第4个顶点受到其他3个顶点的约束。

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

如果您有3个顶点,则可以使用:仿射变换算法计算仿射变换矩阵

To achieve the infinite repeat, use UIImageResizingMode.Tile.

要实现无限重复,请使用UIImageResizingMode.Tile。

#1


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.

您可以使用UIView.transform或CALayer.transform实现该动画。您需要基本几何体将UV坐标转换为CGAffineTransform或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.

我假设仿射变换就足够了,因为在动画中变换是仿射的(平行线保持平行)。在这种情况下,3个顶点是*的 - 第4个顶点受到其他3个顶点的约束。

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

如果您有3个顶点,则可以使用:仿射变换算法计算仿射变换矩阵

To achieve the infinite repeat, use UIImageResizingMode.Tile.

要实现无限重复,请使用UIImageResizingMode.Tile。