3

私は新しい iOS 開発者です。2つのView Controller間の遷移アニメーションを作成したい

どのようにできるのか ?

ここに私のコードがあります:

int newScreenDegrees = _screenDegrees - 90;
[UIView transitionWithView:self.containerView
                  duration:0.65f
                   options:UIViewAnimationOptionCurveEaseInOut
                animations:^{
                    for(int i = 0; i < [self.screens count]; i++)
                    {
                        UIViewController *_screen = [self.screens objectAtIndex:i];

                        int curDeg = newScreenDegrees + i * SPACE_PER_SCREEN;
                        float curRad = convertDegreesToRadians(curDeg);

                        float newX = COORDINATES_CENTER_OF_CIRCLE_X + (CIRCLE_RADIUS * cos(curRad)) - (_screen.view.frame.size.width / 2) - 280;
                        float newY = COORDINATES_CENTER_OF_CIRCLE_Y + (CIRCLE_RADIUS * sin(curRad)) - (_screen.view.frame.size.height / 2);
                        // transform view
                        _screen.view.transform = transformMakeRotateTranslate(convertDegreesToRadians(curDeg + 90), newX, newY);

                    }
                }
                completion:^(BOOL finished){
                    _screenDegrees = newScreenDegrees;

                    // TODO: init content of current view and clear other views

                }];
_screenDegrees = newScreenDegrees;

問題は次のとおりです。ビューは円ではなく線に沿って移動します。

ありがとう

ここに画像があります:http://i.stack.imgur.com/xVQb3.jpg

4

1 に答える 1

1

複数のループがあり、ビューを個別に移動する必要があります。ビューが円形に移動しているように見えるように、移動する円を十分に小さいセグメントに分割します。

for(int i = 0; i < [self.screens count]; i++)
{                
    UIViewController *_screen = [self.screens objectAtIndex:i];
    int newScreenDegrees = i*90;
    int numSegs=30; //break into little chunks
    int segSize=3;//3 degrees
    for (int m=1;m<=numSegs;m++)
    {
         [UIView transitionWithView:self.containerView
              duration:0.65f
               options:UIViewAnimationOptionCurveEaseInOut
            animations:^{

                    int curDeg = newScreenDegrees+m*segSize;
                    float curRad = convertDegreesToRadians(curDeg);

                    float newX = COORDINATES_CENTER_OF_CIRCLE_X + (CIRCLE_RADIUS * cos(curRad)) - (_screen.view.frame.size.width / 2) - 280;
                    float newY = COORDINATES_CENTER_OF_CIRCLE_Y + (CIRCLE_RADIUS * sin(curRad)) - (_screen.view.frame.size.height / 2);
                    _screen.view.transform = transformMakeRotateTranslate(convertDegreesToRadians(curDeg), newX, newY);


            }
            completion:^(BOOL finished){
                _screenDegrees = newScreenDegrees;

                // TODO: init content of current view and clear other views

            }];
     }
}
于 2012-11-15T12:46:08.583 に答える