Flashes on the screen during execution

Here is my code,

egg[0] = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Big_egg.png"]];
egg[0].transform = CGAffineTransformMakeScale(0.0, 0.0);
egg[0].alpha = 1;
[self addSubview:egg[0]];

      

I want to rotate the egg and increase the size of the egg at the same time, my code for this,

[ UIView beginAnimations:nil context:nil];
[ UIView setAnimationCurve: UIViewAnimationCurveLinear ] ;
[ UIView setAnimationDuration:3.0 ];    
egg[0].transform = CGAffineTransformMakeScale(1.0, 1.0);
egg[0].transform = CGAffineTransformRotate(egg[0].transform,2*M_PI/180.0);
[ UIView commitAnimations] ;

      

Due to this I got a flashing on the screen, at runtime, I want to remove it. Is there a way to do this?

0


a source to share


1 answer


It looks like you have several issues that might be causing problems.

First, you don't scale to 1.0, 1.0 is a scale factor of 1 in both x and y directions. choose a number greater or less than 1, I chose 0.5.



Second, you set the transform twice. just set it once, create a temporary variable to hold it while you manipulate it (common Cocoa template):

   CGAffineTransform tempTransform = CGAffineTransformScale(egg[0].transform, 0.5, 0.5);
   tempTransform = CGAffineTransformRotate(tempTransform, 2*M_PI/180.0);
   egg[0].transform = tempTransform;

      

0


a source







All Articles