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 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
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*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Name
Email
Subject
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.