gpt4 book ai didi

ios - 如何在 iOS 中沿圆圈移动 View Controller

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:23:39 26 4
gpt4 key购买 nike

我是 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;

问题是: View 沿着一条线而不是圆移动。

谢谢

这是图片:http://i.stack.imgur.com/xVQb3.jpg

最佳答案

您需要有多个循环并单独移动 View 。将移动的圆圈分成足够小的部分,看起来 View 正在以圆形方式移动。

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

}];
}
}

关于ios - 如何在 iOS 中沿圆圈移动 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13397689/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com