简体   繁体   中英

swift orientation view changes

I've search quite a bit to find information on view changes in IOS application while using swift. I've trying to do following with a orientation change for a particular view. I've a vie with list of buttons (4) arrange like a list when device in portrait mode but I want to display them as 4 square button in a two row when device switched to landscape mode.

For example, in portrait mode

| Button 1 |


| Button 2 |


| Button 3 |


| Button 4 |

In landscape mode,


| Button 1 Button 2 |

| Button 3 Button 4 |


I don't know if I need to build dynamic view for landscape mode to achieve this? Any ideas/help is appreciated.

Use the Vary for Traits feature in the InterfaceBuilder .

  1. Select the Vary for Traits option, the check the Width option

    因性状而异-宽度

  2. Select Landscape under Device options

  3. Make desired changes, in your case rearrange buttons to the new layout

  4. Click the Done Varying button

That's it. InterfaceBuilder has now setup the variations. Switch the orientation to see for yourself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM