Objective c 如何在iOS中以圆形方向旋转UI按钮?
我想在圆周方向上旋转这三个按钮,这样所选的按钮将到达中心,其他相应的按钮将得到相应的交换 更具体地说-->如果单击“按钮2”,它将进入中心位置,即“按钮3”的当前位置,“按钮3”也将切换为“按钮1” 然后,如果我再次单击该按钮(按钮2),它将转到下一页(下一个ViewContoller) 谁能帮我实现这一目标Objective c 如何在iOS中以圆形方向旋转UI按钮?,objective-c,ios,Objective C,Ios,我想在圆周方向上旋转这三个按钮,这样所选的按钮将到达中心,其他相应的按钮将得到相应的交换 更具体地说-->如果单击“按钮2”,它将进入中心位置,即“按钮3”的当前位置,“按钮3”也将切换为“按钮1” 然后,如果我再次单击该按钮(按钮2),它将转到下一页(下一个ViewContoller) 谁能帮我实现这一目标 如果可能,请提供示例应用程序的任何示例代码或链接 假设您将3个按钮声明为IVAR,那么您需要执行以下操作: - (void)rotateLeft { CGRect frame1 =
如果可能,请提供示例应用程序的任何示例代码或链接 假设您将3个按钮声明为IVAR,那么您需要执行以下操作:
- (void)rotateLeft {
CGRect frame1 = button1.frame;
CGRect frame2 = button2.frame;
CGRect frame3 = button3.frame;
[UIView animateWithDuration:.5 animations:^{
[button1 setFrame:frame3];
[button2 setFrame:frame1];
[button3 setFrame:frame2];
}];
}
- (void)rotateRight {
CGRect frame1 = button1.frame;
CGRect frame2 = button2.frame;
CGRect frame3 = button3.frame;
[UIView animateWithDuration:.5 animations:^{
[button1 setFrame:frame2];
[button2 setFrame:frame3];
[button3 setFrame:frame1];
}];
}
- (IBAction)buttonPressed:(id)sender {
UIButton* clicked = (UIButton*)sender;
if (clicked.frame.origin.x == 20) {
[self rotateLeft];
} else if (clicked.frame.origin.x == 228) {
[self rotateRight];
} else {
[self.navigationController pushViewController:[[NextController alloc] init] animated:YES];
}
}
这将使用“帧”属性检测旋转的方向。但是,您应该从中了解大致情况。您需要查看UIView动画 基本上,当按下其中一个按钮时,需要为每个按钮的中心属性设置动画。非常简单的东西
如果你需要帮助,网上有很多教程。你希望有人帮你写这篇文章,还是你忘了分享你的代码?我已经创建了一个带有固定UIButtons的示例应用程序,但我没有制作动画,所以请给我一些继续的指导。谢谢回复,你能提供教程的链接吗?这个问题可能会帮助你。。。谢谢,这有助于我创建基本的正常帧移动序列,现在我正在努力创建更好的外观。非常感谢你在这方面的指导方针。