Random text to fade -
how random text fade, text1
text2
?
my code follows:
-(ibaction)generatenumbers; { int randomnumber = arc4random() % 1; switch (randomnumber) { case 0: label.text = @"text1"; break; case 1: label.text = @"text2"; break; default: break; } }
-(ibaction)generatenumbers; { int randomnumber = arc4random() % 2; switch (randomnumber) { case 0: label.text = @"text1"; break; case 1: label.text = @"text2"; break; default: break; } }
for fadein/out use methods
- (void) settextwithfade { [label setalpha:1]; [uiview beginanimations:nil context:nil]; [uiview setanimationduration:1]; [uiview setanimationdelegate:self]; [uiview setanimationdidstopselector:@selector(fadedidstop)]; [lbl setalpha:0]; [uiview commitanimations]; } - (void)fadedidstop { label.text = @"new text"; [uiview beginanimations:nil context:null]; [uiview setanimationduration:1]; [lbl setalpha:1]; [uiview commitanimations]; }
call first method when click button this:
[self settextwithfade];
Comments
Post a Comment