簡體   English   中英

方向上的旋轉按鈕更改為橫向視圖

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM