ios - iPhone - UIImageView moves when Rotate Animation > 90 degree -


I am using this code to rotate my image

  - ( IBAction) Spin: (ID) sender {[UIView startAnimations: zero reference: zero]; [UIView Set Animation Duration: 5.0]; [UIView Set AnimationBuginFrenchTant: Yes]; self.imgRad.transform = CGAffineTransformMakeRotation (arc4random ()% 360 * M_PI / 180); [UIView commitAnimations]; }   

Now I have two problems.

First: If the random number is greater than 90, then the image rotates near its center in the right corner and in relation to its random number. So much more number = the position of the image is close to the right corner. How can I fix that? Do I have to set my new UIImageView every time more than 90?

Second: If the number is for example 300, then the image does not rotate 300 degrees, it spins only 60 degrees on the other side. How can I fix this problem?

Thank you very much!

  • The first problem may be due to an incorrect signal point when using the transformer CAAnimation .
  • The second problem can be solved by using NSNumber .

    Code: CABasicAnimation * rotation = [with CABasic Animation Animation: @ "Transformation.Rotation"]; Rotation.fromValue = [Flow with NSNumber Number: 0]; Rotation.toValue = [with NSN number number Flat: (ARC4RRM (~% 360 * M_PI / 180)] rotation.duration = 5.0f; rotation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut]; Rotation.fillMode = kCAFillModeForwards; Rotation. removedOncompletion = no; [self. imgRad.layer addAnimation: for rotation forkey: @ "rotatationRandom"];

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -