复杂的CATransition
我正在尝试创建一个 CATransition
到 UIView
。
我想将 UIView
移动到右侧,同时(并且始终在同一点上)旋转它。
通过图像可以更好地解释。
我可以使用 CATransition 移动它,也可以使用 CABasicAnimation 旋转它,但我不知道如何一起执行这些操作。
谢谢。
I am trying to create a CATransition
to a UIView
.
I want to move the UIView
to the right, and at the same time (and always on the same point), rotate it.
It is better explained by the image.
I am able to move it with a CATransition
, and also to rotate it with a CABasicAnimation
, but I don't know how to do those together.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
-(void)scaleAndRotate:(UIImageView*)myView andAngle:(float)angle {
}
在上面的方法中:替换 &和你想要的...
一定会成功的:)
一切顺利
-(void)scaleAndRotate:(UIImageView*)myView andAngle:(float)angle {
}
In the above method : replace & with what u want ...
It'll work ,,, surely :)
All the best
您应该考虑制作图像的两个副本,旋转其中一个,然后对它们进行遮罩,以便它们可以以 L 形状彼此相邻放置。
使用这种技术,您将同时对图像 A 和 T 进行两次转换(移动蒙版和底层图像)。但是,请注意,旋转不会被动画化。您将立即将图像 T 置于旋转状态,然后通过将其移动到蒙版下方来显示它(同时在图像 A 上执行相反的操作以隐藏它)。因此,您实际上并不是将平移和旋转组合到一个动画中,而是仅在原始图像 (A) 和旋转副本 (T) 上使用带有蒙版的平移。
您需要遮盖其中一个的左侧和另一个的右侧。蒙版的形状应该在两个方向上都有相反的 45 度角,然后您可以将这些有角度的边缘组合在一起形成 L。随着时间的推移,您只需移动每个蒙版,直到第一个图像完全消失,您就可以了留下你的最终状态。
遮罩部分是最难的部分。请参阅有关使用 CoreGraphics 屏蔽 UIImage 的答案: 屏蔽 UIImage
屏蔽 PNG 基本上会只是一个边长为 45 度角的矩形。您可以在您选择的图像编辑器(Photoshop、GIMP、Acorn)中创建它。
注意:这种方法会在拐角处形成锋利的边缘。另一种方法是当像素从垂直向下运动移动到水平向右运动时,使该角周围的像素变形。 (我认为)这会涉及更多。
You should consider making two copies of the image, rotating one, and masking them both so that they can be placed next to each other in the L shape.
Using this technique, you'll be doing two translations at once (moving the mask and the underlying image) to both images A and T. But, notice that rotation will not be animated. You'll put image T into the rotated state immediately and just reveal it by moving it under the mask (while simultaneously doing the opposite on image A to hide it). So you're not actually combining translation and rotation into one animation, but rather using just translation with a mask on both the original image (A) and a rotated copy (T).
You'll need to mask the left side of one and the right side of the other. The shape of the mask should have an opposite 45 degree angle on both, then you can bring those angled edges together to form the L. As time progress, you just move the mask in each until the first image is totally gone and you're left with your end state.
The masking part is the hard part. See this answer on masking a UIImage with CoreGraphics: masking a UIImage
The mask PNG would basically just be a rectangle with one side at a 45 degree angle. You could create that in the image editor of your choice (Photoshop, GIMP, Acorn).
Note: this approach will create a sharp edge at the corner. The other approach would be to warp the pixels around that corner as they move from the vertical downward motion to the horizontal rightward motion. (I think) This would be much more involved.