方法1:
用这种方法退出后台再回来会消失.
DLog(@"开始动画");
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:3.0f];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDelegate:self];
[UIView setAnimationRepeatAutoreverses:NO];
[UIView setAnimationRepeatCount:0];
CGRect frame1 = a.frame;
frame1.origin.x = -a.width - 10;
_name.frame = frame1;
[UIView commitAnimations];
DLog(@"结束动画");
方法2:
- (void)paomaLabel{
[UIView transitionWithView:self duration:3 options:UIViewAnimationOptionCurveLinear animations:^{
CGRect frame1 = _name.frame;
frame1.origin.x = CGRectGetWidth(_portrait.frame)+4 -_name.width - 15;
_name.frame = frame1;
} completion:^(BOOL finished) {
CGRect frame = _name.frame;
frame.origin.x = CGRectGetWidth(_portrait.frame)+4 + _name.width;
_name.frame = frame;
[self paomaXunHuan];
}];
}
- (void)paomaXunHuan{
if (!self.isOpen) {//关了
return;
}
[UIView transitionWithView:self duration:6 options:UIViewAnimationOptionCurveLinear animations:^{
CGRect frame = _name.frame;
frame.origin.x = CGRectGetWidth(_portrait.frame)+4 - _name.width - 15;
_name.frame = frame;
} completion:^(BOOL finished) {
CGRect frame = _name.frame;
frame.origin.x = CGRectGetWidth(_portrait.frame)+4 + _name.width;
_name.frame = frame;
[self paomaXunHuan];
}];
}