Iphone UIButton转换-在屏幕上运行
我在主视图(self.view)上附加了一个UIButton。它在纵向模式下位于(0,0)位置 当用户将iphone切换到横向模式时,我希望按钮在屏幕上显示为运行到位置(200,0) 我要寻找的效果是按钮在视图更改时平滑地来回运行Iphone UIButton转换-在屏幕上运行,iphone,ios,xcode,Iphone,Ios,Xcode,我在主视图(self.view)上附加了一个UIButton。它在纵向模式下位于(0,0)位置 当用户将iphone切换到横向模式时,我希望按钮在屏幕上显示为运行到位置(200,0) 我要寻找的效果是按钮在视图更改时平滑地来回运行 在我的一生中,我在苹果文档或谷歌搜索中都找不到这样的转变。有什么方法可以这样做吗?在视图控制器中执行此操作: - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromOrientati
在我的一生中,我在苹果文档或谷歌搜索中都找不到这样的转变。有什么方法可以这样做吗?在视图控制器中执行此操作:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromOrientation
UIInterfaceOrientation currentOrientation = self.interfaceOrientation;
CGRect buttonFrame = self.button.frame;
if (UIInterfaceOrientationIsPortrait(currentOrientation))
buttonFrame.origin = CGPointMake(0, 0);
else
buttonFrame.origin = CGPointMake(200, 0);
[UIView animateWithDuration:1.0 animations:^ {
self.button.frame = buttonFrame;
}];
}
动画块不适合你的用途吗?