Tuesday, 15 March 2011

ios - fading UIImageView transition -



ios - fading UIImageView transition -

i'd build nice background view images fading out & in. but, animation not stop.

i using :

backgrounduiimageview.animationimages = [uiimage(named:"testimage1"), uiimage(named:"testimage2")] backgrounduiimageview.animationduration = 10 backgrounduiimageview.animationrepeatcount = 0 backgrounduiimageview.startanimating()

problem : transitions not faded

i tried :

var uiimage1=uiimage(named:"testimage1") var uiimage2=uiimage(named:"testimage2") var crossfade = cabasicanimation(keypath:"contents") crossfade.duration = 5.0 crossfade.fromvalue = uiimage1.cgimage crossfade.tovalue = uiimage2.cgimage self.backgrounduiimageview.layer.addanimation(crossfade, forkey:"animatecontents") self.backgrounduiimageview.image = uiimage2

problem : animation not repeated , code ugly & unsafe in opinion..

would have idea/code illustration how ?

i don't know how write in swift, utilize snippet. repeat should add together options uiviewanimationoptionautoreverse , uiviewanimationoptionrepeat

uiimage * toimage = [[uiimage alloc] initwithcontentsoffile:imagepath]; [uiview transitionwithview:self.imageview duration:0.8f options:uiviewanimationoptiontransitioncrossdissolve animations:^{ self.imageview.image = toimage; } completion:nil];

ios xcode animation uiimageview transition

No comments:

Post a Comment