Ios 在UIImageView动画中应用一些缓和
我使用以下方法使UIImageView向前滑动一点,然后再向后滑动一点,以获得视差滚动效果 代码:Ios 在UIImageView动画中应用一些缓和,ios,objective-c,Ios,Objective C,我使用以下方法使UIImageView向前滑动一点,然后再向后滑动一点,以获得视差滚动效果 代码: 我想知道,如果只是突然快速地来回滑动,我现在如何在动画中应用一些缓和。我想轻松地进入和退出滑动动画。查看有关UIView动画的本教程 UIView有一个方法 // [UIView animateWithDuration:(NSTimeInterval) delay:(NSTimeInterval) options:(UIViewAnimationOptions)animations:^(vo
我想知道,如果只是突然快速地来回滑动,我现在如何在动画中应用一些缓和。我想轻松地进入和退出滑动动画。查看有关UIView动画的本教程 UIView有一个方法
// [UIView animateWithDuration:(NSTimeInterval) delay:(NSTimeInterval) options:(UIViewAnimationOptions)animations:^(void)animations completion:^(BOOL finished)completion];
typedef enum {
UIViewAnimationCurveEaseInOut, // slow at beginning and end
UIViewAnimationCurveEaseIn, // slow at beginning
UIViewAnimationCurveEaseOut, // slow at end
UIViewAnimationCurveLinear
}
[UIView animateWithDuration:0.6f
delay:0.1f
options:UIViewAnimationCurveEaseInOut
animations:^{
[starView setCenter:CGPointMake(0, 0)];
[starView setAlpha:0.0f];
}
completion:^(BOOL finished){
[starView removeFromSuperview];
points++;
}
];
还可以在github上查看此控件,它使用自定义容器视图创建视差效果,非常类似于Path的时间线的俯视图。
这将实现以下目的:
[UIView animateWithDuration:0.2f delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^(void){
//do your animations
} completion:^(BOOL finished){
}];
第一个动画块完成后,需要执行第二个动画块
[UIView animateWithDuration:0.2f animations:^{
spendrBckGrnd.frame = CGRectMake(spendrBckGrnd.frame.origin.x + 20, 0, spendrBckGrnd.frame.size.width, spendrBckGrnd.frame.size.height);
} completion:^{
[UIView animateWithDuration:0.2f animations:^(BOOL finished){
spendrBckGrnd.frame = CGRectMake(spendrBckGrnd.frame.origin.x - 80, 0, spendrBckGrnd.frame.size.width, spendrBckGrnd.frame.size.height);
}];
}];
就是这样,真不敢相信我没有从UIView中捕获其他静态方法。顺便说一句,你的代码就像我需要的那样工作,但是你需要添加(BOOL finished)到我相信的第二个块中
[UIView animateWithDuration:0.2f animations:^{
spendrBckGrnd.frame = CGRectMake(spendrBckGrnd.frame.origin.x + 20, 0, spendrBckGrnd.frame.size.width, spendrBckGrnd.frame.size.height);
} completion:^{
[UIView animateWithDuration:0.2f animations:^(BOOL finished){
spendrBckGrnd.frame = CGRectMake(spendrBckGrnd.frame.origin.x - 80, 0, spendrBckGrnd.frame.size.width, spendrBckGrnd.frame.size.height);
}];
}];