[英]How to animate from UiImageView to a UIView
I use Path2.0. 我使用Path2.0。 I have found that when I click the small picture in a message,there would be an animation to show the whole picture. 我发现当我单击消息中的小图片时,会有一个动画来显示整个图片。 How does it do that? I would really appreciate help here. 它是怎么做到的?我真的很感谢您的帮助。 Thanks! 谢谢!
UiImageView is bascially a UIView, which you can apply animation on. UiImageView基本上是一个UIView,您可以在上面应用动画。
The use case you want to achieve combines: 您想要实现的用例结合了:
a. 一种。 a response to touch event, which you can use UITapGestureRecoginizer to attache a block of code 对触摸事件的响应,您可以使用UITapGestureRecoginizer附加代码块
b. b。 zoom the UIImageView into a proper size and position, you can use UIView's class method AnimiationWithDuration .... 将UIImageView缩放到适当的大小和位置,可以使用UIView的类方法AnimiationWithDuration ...。
c. C。 Ultimately, you want to change your UIImageView's frame property to a larger one. 最终,您希望将UIImageView的frame属性更改为更大的属性。 use CGRectMake to generate a new one. 使用CGRectMake生成一个新的。 If you need to take the whole screen estate (like Path 2.0 does), you may need [UIApplication sharedApplication] .window for this 如果您需要占用整个屏幕空间(如Path 2.0一样),则可能需要[UIApplication sharedApplication] .window为此
I doubt they modify the original UIImageView; 我怀疑他们会修改原始的UIImageView; but a solution might be: 但解决方案可能是:
CGAffineTransformMakeScale()
function on a UIView's transform
property (inside a UIView animation block) 在UIImageView上应用缩放变换(通过在UIView的transform
属性上使用CGAffineTransformMakeScale()
函数(在UIView动画块内部) Alternatively, you could instantiate the new subview with the full image, set it with the original UIImageView's frame, and then (using a UIView animation block), set it to the newer frame. 或者,您可以实例化具有完整图像的新子视图,并使用原始UIImageView的框架进行设置,然后(使用UIView动画块)将其设置为较新的框架。 To match their implementation exactly, I suggest a black subview (of the full UIImageView) with an alpha of 0.0 that you then animate at the same duration to an alpha of 1.0. 为了完全匹配它们的实现,我建议(整个UIImageView的)黑色子视图的alpha值为0.0,然后在相同的时间段将其动画为alpha值为1.0。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.