Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 18.104.22.168 release ready!
Updated 27 April 2023
There are a lot of apps nowadays which we want to use in only landscape or portrait mode according to our preference. Today we are going to implement lock screen orientation in swift.
We can set orientation according to our requirement i.e. portrait or landscape. Let’s check how can we implement lock screen orientation in swift.
Step 1: Create a new iOS project & select device orientation as per the requirement in Runner.
Step 2: Add supported Orientation method in App Delegate.
Step 3: Create 2 buttons for selecting the landscape & portrait orientation.
Step 4: Create action outlets for these buttons in view controller.
Step 5: Create a global helper class to adjust the lock & rotate it to the desired orientation.
Step 6: Use lockOrientation method on the button action in the view controller to lock orientation & rotate the screen.
In this article, I have explained how to lock screen orientation, which you can modify and experiment with according to your own.
Thanks for reading this article ❤
If I got something wrong 🙈, let me know in the comments. I would love to improve.
For more interesting blogs check out here – https://mobikul.com/blog/
Reference link: https://www.polpiella.dev/changing-orientation-for-a-single-screen-in-swiftui
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.