CATransitionFade not working on newly added subviews
Posted
by David Liu
on Stack Overflow
See other posts from Stack Overflow
or by David Liu
Published on 2010-05-18T01:44:38Z
Indexed on
2010/05/18
1:50 UTC
Read the original article
Hit count: 373
For some reason, fading in new buttons using CATransition isn't working for me when it's a newly added button. The fade animation, however, is working on existing subviews.
Code:
// Add new button.
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionFade];
[[button layer] addAnimation:animation forKey:@"fadeIn"];
[self.view addSubview:button];
// Enable previous button (Enabling fades in different type of background)
if(toolbar.buttons.count != 0){
UIButton * prevButton = [toolbar.buttons objectAtIndex:(toolbar.buttons.count - 1)];
prevButton.enabled = YES;
[[prevButton layer] addAnimation:animation forKey:@"fadeIn"];
}
© Stack Overflow or respective owner