#pragma mark 动画消失
-(void)dismiss
{
center.y = center.y+self.view.frame.size.height;
[UIView animateWithDuration: 0.35 animations: ^{
// 获取到当前的View
CALayer *viewLayer = self.shopCarBackView.layer;
// 获取当前View的位置
CGPoint position = viewLayer.position;
// 移动的两个终点位置
CGPoint x = CGPointMake(position.x + 10, position.y);
CGPoint y = CGPointMake(position.x - 10, position.y);
// 设置动画
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
// 设置运动形式
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];
// 设置开始位置
[animation setFromValue:[NSValue valueWithCGPoint:x]];
// 设置结束位置
[animation setToValue:[NSValue valueWithCGPoint:y]];
// 设置自动反转
[animation setAutoreverses:YES];
// 设置时间
[animation setDuration:.06];
// 设置次数
[animation setRepeatCount:5];
// 添加上动画
[viewLayer addAnimation:animation forKey:nil];
} completion: nil];
}
本人个人微信公众号地址(喜欢记得关注😯)
辛小二个人微信公众号地址
网友评论