[英]Rotate Button On Orientation Changed to Landscape View
我正在制作一个油漆应用程序..标有红色圆圈的按钮,我希望它旋转 90 度“当方向更改为横向模式时”.. 标有红色圆圈的图像放置在按钮上.. 所以我应该旋转按钮或方向改变时的图像?
希望这个描述能让你了解我的问题..谢谢..
请点击此链接查看屏幕截图,因为我不允许发布图像..
http://imageshack.us/photo/my-images/26/screenshot20110712at507.png/
你可以做任何一个,但我认为将图像翻转 90 度会更容易。 当您的应用程序切换到横向时,有一个新图像,实际上只是将旧图像转了 90 度,并将其设置为按钮的图像。 希望这可以帮助。
嗯,这是一个甜蜜的交易。 只需将以下代码复制粘贴到您的视图 controller (您希望在其中旋转按钮的代码)。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
if (interfaceOrientation == UIInterfaceOrientationPortrait ||
interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight)
return YES;
else {
return NO;
}}
这可能会让你知道你的目标。 快乐编码..!
您可以通过以下方法设置 UIButton 的框架,如下所示:
在.h class
IBOutlet UIButton *redButton;
和 in.m class:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
if (interfaceOrientation == UIInterfaceOrientationPortrait)
{
redButton.frame = CGRectMake(100,50,100,50)
}
else
{
redButton.frame = CGRectMake(50,100,100,50)
}
return YES;
}
因此,您可以根据需要更改按钮的框架。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.