[英]How do I make a bounce effect after slide effect in xcode?
我有這段代碼,只要slide to left
滑動
[UIView animateWithDuration:1.0 delay:2.0 options:(UIViewAnimationCurveEaseInOut|UIViewAnimationOptionAllowUserInteraction)
animations:^
{
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(faceRight:finished:context:)];
self.bug.center = CGPointMake(75, 200);
}
completion:^(BOOL finished)
{
NSLog(@"Move to left done");
}
];
但我想添加1反彈效果,也許添加如下代碼:
self.bug.center = CGPointMake(78, 200);
但我不知道如何添加此代碼,我應該在哪里寫呢? 我是動畫新手。 請幫忙 :)
-(void)onTimer
{
ball.center = CGPointMake(ball.center.x+pos.x,ball.center.y+pos.y);
if(ball.center.x > 320 || ball.center.x < 0)
pos.x = -pos.x;
if(ball.center.y > 460 || ball.center.y < 0)
pos.y = -pos.y;
}
-(your method)
{
pos = CGPointMake(14.0,7.0);
[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
}
您應該使用基於塊的動畫方法,該方法在文檔中說,建議使用塊。 此外,在iOS 7中,UIView具有一種新的+方法,可以完成此操作。 或者,您可以使用UIkit Dynamics系統。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.