странный вид с основной анимацией - PullRequest
0 голосов
/ 13 января 2012

Вот код:

 UIImageView * imgView = [[UIImageView alloc] initWithImage:image];



                CGRect imgFrame = imgView.frame;
                imgFrame.size.width = originalImageSize.width;
                imgFrame.size.height = originalImageSize.height;
                imgFrame.origin.x = 110;
                imgFrame.origin.y = 215;
                imgView.frame = imgFrame;

[UIView beginAnimations:nil context:NULL];
                [UIView setAnimationDuration:10];

                CGRect frame = imgView.frame;
                frame.size.width = SCREEN_WIDTH_PORTRAIT;
                [imgView setFrame:frame];
                 [imgView setCenter:CGPointMake(SCREEN_WIDTH_PORTRAIT/2, (SCREEN_HEIGHT_PORTRAIT)/2)];

 [fullSizeImageView setBackgroundColor:[UIColor blackColor]];
                [UIView commitAnimations];

Не уверен, почему, когда анимация запускается, она смещается немного вправо на некоторое большое расстояние.Любая идея?Вот видео

1 Ответ

0 голосов
/ 13 января 2012

Попробуйте setCenter до beginAnimations

imgView.center = CGPointMake(SCREEN_WIDTH_PORTRAIT/2, yYouLike);

Ваш код должен выглядеть следующим образом:

UIImageView * imgView = [[UIImageView alloc] initWithImage:image];

                CGRect imgFrame = imgView.frame;
                imgFrame.size.width = originalImageSize.width;
                imgFrame.size.height = originalImageSize.height;
                imgFrame.origin.x = 110;
                imgFrame.origin.y = 215;
                imgView.frame = imgFrame;

imgView.center = CGPointMake(SCREEN_WIDTH_PORTRAIT/2, yYouLike);

[UIView beginAnimations:nil context:NULL];
                [UIView setAnimationDuration:10];

                CGRect frame = imgView.frame;
                frame.size.width = SCREEN_WIDTH_PORTRAIT;
                [imgView setFrame:frame];
                 [imgView setCenter:CGPointMake(SCREEN_WIDTH_PORTRAIT/2, (SCREEN_HEIGHT_PORTRAIT)/2)];

 [fullSizeImageView setBackgroundColor:[UIColor blackColor]];
                [UIView commitAnimations];

Тогда, если ваша цель - iOS 4.0 или более поздняя, ​​этолучше использовать блочные методы анимации, как написано здесь: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIView_Class/UIView/UIView.html

...