ios - Execute animation of subview subclass -
ios - Execute animation of subview subclass -
i have uiviewcontroller called parentviewcontroller. , have uiview custom class called customview. including imageview , function execute animation.
customview.h
@interface customview : uiview @property (weak, nonatomic) iboutlet uiimageview *human; @property (weak, nonatomic) iboutlet uiimageview *shadow; + (id)customview; - (void)executeanimation; @end
and in customview.m ave executeanimation following:
-(void)executeanimation{ self.animation1inprogress = yes; [uiview animatekeyframeswithduration:3.0 delay:0.0 options:uiviewanimationcurvelinear animations:^{ self.human.frame = cgrectmake(self.human.frame.origin.x, self.human.frame.origin.y + 300, self.human.frame.size.width, self.human.frame.size.height); } completion:^(bool finished){ self.animation1inprogress = no; }]; }
now in parentviewcontroller.m, add together customview without animation
//init custom customview = [customview initcustomview]; [self.view addsubview:centerlocationview];
this code ok. init , addsubview parentviewcontroller. whenever execute animation customview. phone call next coding in parentviewcontroller.m:
[customview executeanimation];
there nil changed @ parent view. know way execute animation @ parentviewcontroller?
thank in advance.
if want utilize +[uiview animatekeyframeswithduration:delay:options:animations:completion:]
, should add together keyframes animations
block:
-(void)executeanimation{ self.animation1inprogress = yes; [uiview animatekeyframeswithduration:3.0 delay:0.0 options:uiviewanimationcurvelinear animations:^{ [uiview addkeyframewithrelativestarttime:0.0 relativeduration:1.0 animations:^{ self.human.frame = cgrectmake(self.human.frame.origin.x, self.human.frame.origin.y + 300, self.human.frame.size.width, self.human.frame.size.height); }]; } completion:^(bool finished){ self.animation1inprogress = no; }]; }
otherwise, utilize [uiview animatewithduration:animations:completion:]
:
-(void)executeanimation{ self.animation1inprogress = yes; [uiview animatewithduration:3.0 delay:0.0 options:uiviewanimationcurvelinear animations:^{ self.human.frame = cgrectmake(self.human.frame.origin.x, self.human.frame.origin.y + 300, self.human.frame.size.width, self.human.frame.size.height); } completion:^(bool finished){ self.animation1inprogress = no; }]; }
ios objective-c animation uiview
Comments
Post a Comment