문제

I use this code to move my view

[UIView animateWithDuration:0.3 animations:^{
    [MyView setTransform:CGAffineTransformMakeTranslation(260, 0)];
} completion:^(BOOL finished) {
}];

MyView is a subview of self.view

I want to move it to right with 260

but it will first move to left with 130 and no animate

and then move to right with 260 and animate

I don't know why MyView move to left first?

도움이 되었습니까?

해결책

The problem is that you are using auto layout. For a simple animation, trying turning off auto layout in storyboard.

Your animation should work then as expected.

다른 팁

I guess the problem is that the MakeTranslation function is making your view reset it's position before animating to the new transform.

Try this:

[UIView animateWithDuration:0.3 animations:^{
    [MyView setTransform:CGAffineTransformTranslate(myView.transform, 260, 0)];
} completion:^(BOOL finished) {
}];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top