Saturday, 15 February 2014

How to change the background color of UIView with delay/animation: Xcode/cocos2d

We can change the background color of an UIView with delay as follows. This can be also used for many other UIElement animations such as changing the properties of an UIButton (such as textColor) with delay/animation.


 [UIView animateWithDuration:2.0 animations:^{
    [myView setBackgroundColor:[UIColor grayColor]];
 }
    

How to set UIImageView image with delay/animation: Xcode/Cocos2d

We can set the image of an UIImageView with delay/animation as follows:


[UIView transitionWithView:myImageView
                      duration:1.0
                       options:UIViewAnimationOptionTransitionCrossDissolve
                    animations:^{
                        myImageView.image = [UIImage imageNamed:@"newImage.png"];
                    } completion:nil];