UIView振荡运动

时间:2015-05-09 11:38:57

标签: ios objective-c animation

如何完成模仿钟摆运动的UIView动画(在本例中为图像视图)?我希望它从左向右摆动并重复。

1 个答案:

答案 0 :(得分:1)

[UIView animateKeyframesWithDuration:0.3f delay:0.f options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse animations:^{
    [self.imgview setFrame:CGRectMake(self.imgview.frame.origin.x + 50 ,self.imgview.frame.origin.y, self.imgview.frame.size.width, self.imgview.frame.size.height)];

} completion:^(BOOL finished) {

}];