简体   繁体   English

有时无法在动画块中旋转和设置UIView的中心

[英]Rotation and Setting center of UIView in animation block doesn't work sometimes

What I want to do is to rotate and bounce my UIView simultaneously. 我想做的是同时旋转并弹起UIView So currently, I am using this code in my UIViewAnimation block. 因此,目前,我正在UIViewAnimation块中使用此代码。

[view setTransform:CGAffineTransformRotate(CGAffineTransformIdentity, -M_PI*2)];
CGPoint center = CGPointMake( view.center.x - x , view.center.y - y);
[view setCenter:center];

And using this, its rotation is happening fine but the view bouncing is not happening ie not any kind of movement is happening at all. 并且使用它,它的旋转进行得很好,但是视图跳动却没有发生,即根本没有任何运动发生。 Guidance needed on what I am doing wrong here of if I am missing something. 如果我错过了一些东西,需要对我在这里做错的事情进行指导。

Use the transform to do both things by applying a rotation and a translation (be careful of the order you apply them in). 使用变换通过应用旋转和平移来完成这两项操作(请注意应用它们的顺序)。 When you apply a transform to a view you shouldn't then try to change its frame (or center). 当将变换应用于视图时,则不应尝试更改其框架(或中心)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM