iOS UIView transition, don't change the navigationbar -
i have uiviewcontroller
edit using ib. put uinavigationbar
, uisegmentedcontrol
on top , 3 uiviews
under them. want able switch between uiviews
using animation, want animate uiviews
, want navigationbar , athe segmentedcontrol not move. show code how now.
any idea how move 3 views?
- (ibaction)segmentedcontrolvaluechanged:(id)sender { uisegmentedcontrol* segmentedcontrol = sender; if(lastselectedviewindex != [segmentedcontrol selectedsegmentindex]) { catransition *transition = [catransition animation]; transition.duration = 0.4; transition.timingfunction = [camediatimingfunction functionwithname:kcamediatimingfunctioneaseineaseout]; transition.type = kcatransitionmovein; if(lastselectedviewindex < [segmentedcontrol selectedsegmentindex]) transition.subtype = kcatransitionfromleft; else transition.subtype = kcatransitionfromright; transition.removedoncompletion = yes; // force removal of animation when completed. { switch ([segmentedcontrol selectedsegmentindex]) { case 0: [self.usagescenarioview sethidden:no]; [self.logincredentialsview sethidden:yes]; [self.whatitcoversview sethidden:yes]; [self.pagecontrol setcurrentpage:0]; break; case 1: [self.usagescenarioview sethidden:yes]; [self.logincredentialsview sethidden:no]; [self.whatitcoversview sethidden:yes]; [self.pagecontrol setcurrentpage:1]; break; case 2: [self.usagescenarioview sethidden:yes]; [self.logincredentialsview sethidden:yes]; [self.whatitcoversview sethidden:no]; [self.pagecontrol setcurrentpage:2]; break; } } lastselectedviewindex = [segmentedcontrol selectedsegmentindex]; [self.view.layer addanimation:transition forkey:nil]; } }
say 3 views named view1, view2, view3. if want remove view1 , show view2 or view3, existing code, change
[self.view.layer addanimation:transition forkey:nil];
into
[view1.layer addanimation:transition forkey:nil];
that animate view1 not whole view. can try,
[view2.layer addanimation:transition forkey:nil]; [view3.layer addanimation:transition forkey:nil];
more precisely, like
transition.removedoncompletion = yes; // force removal of animation when completed. { switch ([segmentedcontrol selectedsegmentindex]) { case 0: [self.usagescenarioview sethidden:no]; [self.logincredentialsview sethidden:yes]; [self.whatitcoversview sethidden:yes]; [self.pagecontrol setcurrentpage:0]; [self.usagescenarioview.layer addanimation:transition forkey:nil]; break; case 1: [self.usagescenarioview sethidden:yes]; [self.logincredentialsview sethidden:no]; [self.whatitcoversview sethidden:yes]; [self.pagecontrol setcurrentpage:1]; [self.logincredentialsview.layer addanimation:transition forkey:nil]; break; case 2: [self.usagescenarioview sethidden:yes]; [self.logincredentialsview sethidden:yes]; [self.whatitcoversview sethidden:no]; [self.pagecontrol setcurrentpage:2]; [self.whatitcoversview.layer addanimation:transition forkey:nil]; break; } } lastselectedviewindex = [segmentedcontrol selectedsegmentindex]; }
Comments
Post a Comment