2014-02-25 2 views
0

현재 모션 그룹이 연결된 UIImageView의 프레임을 변경하려고 할 때 오프셋 글리치를 제거하는 방법을 찾기 위해 고심하고 있습니다.UIMotionEffectGroup 오프셋 글리치

[self.backImageView removeMotionEffect:self.motionGroup]; 
[UIView animateWithDuration:0.3 animations:^{ 
    CGRect frame = self.backImageView.frame; 
    frame.origin.x = self.originalBackImageViewOffset.x + 40; 
    self.backImageView.frame = frame; 
} completion:^(BOOL finished) { 
    self.originalBackImageViewOffset = self.backImageView.frame.origin; 
    [self.backImageView addMotionEffect:self.motionGroup]; 
}]; 

약간의 결함이이 방법으로 장치가있는 경우 : 난 내가 할 원점을 변경해야하는 경우 지금

UIInterpolatingMotionEffect *xAxis = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis]; 
xAxis.minimumRelativeValue = @(-25.0); 
xAxis.maximumRelativeValue = @(25.0); 

self.motionGroup = [[UIMotionEffectGroup alloc] init]; 
self.motionGroup.motionEffects = @[xAxis]; 

[self.backImageView addMotionEffect:self.motionGroup]; 

:

은 모션 효과를 추가하는 코드입니다 기울어 진. 그것은 removeMotionEffect 바로 다음에 나타납니다 : imageView가 원래 상태로 전환되고 프레임이 바뀔 때까지. 전화기가 기울어 있지 않으면 (시뮬레이터에서) 글리치가 보이지 않습니다.

애니메이션 그룹을 제거하지 않으면 더 큰 결함이 있습니다. 애니메이션 중에는 휴대 전화를 기울입니다.

누구든지이 문제를 극복하는 방법을 알고 있습니까?

p.s. 태그 "UIMotionEffectGroup"또는 "UIMotionEffect"를 만드는 데 충분한 평판이 없습니다.

답변

0

대신 프레임을 애니메이션으로, 다음, 변환을 적용 애니메이션 모션 효과를 제거하지 않고 완료 될 때 프레임을 설정

[UIView animateWithDuration:0.3 animations:^{ 

    self.backImageView.transform = CGAffineTransformMakeTranslation(40, 0); 
} completion:^(BOOL finished) { 
    CGRect frame = self.backImageView.frame; 
    frame.origin.x = self.originalBackImageViewOffset.x + 40; 
    self.backImageView.frame = frame; 
    self.originalBackImageViewOffset = self.backImageView.frame.origin; 
}]; 
+0

감사합니다 오스틴,하지만 unfortunatelly 글리치는 더 큰 그 방법입니다. –