Home Swift: how to switch statusbar orientation in IOS 9+?
Reply: 1

Swift: how to switch statusbar orientation in IOS 9+?

user594883 Published in 2018-01-13 07:47:42Z

I'm building a game that is based on gestures. IOS' native gestures that bring in notification center and control center on side swipe are super annoying as they interfere with gameplay.

Having searched extensively for a solution, I have come to belive that there is no way to disable/block control center or notification center on app level.

One possible solution that could help that I found was to turn the status bar orientation. My app runs in landscape orientation. If I could switch notification/control centers from top and bottom swipe to left and right swipes, I think that could almoast solve my problem.

However this seems to be possible but depreceted since IOS 9: https://developer.apple.com/documentation/uikit/uiapplication/1622939-setstatusbarorientation?language=objc

Apple suggests to use UITraitCollection instead. However I can't figure out how to change the orientation of the status bar using this. Sample code would be greatly appreciated!

Upholder Of Truth
Upholder Of Truth Reply to 2018-01-13 09:42:42Z

From the same documentation it states:

you should not arbitrarily set status-bar orientation using this method

This is even more true now because if you do try to use this method you get this warning (and it didn't actually work):

'setStatusBarOrientation(_:animated:)' was deprecated in iOS 9.0: Explicit setting of the status bar orientation is more limited in iOS 6.0 and later

This is not something you should be trying to do with your app. Either hide the status bar or leave it at the top.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.315401 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO