While rotate to landscape some view on top shown because of status bar custom view in swift

 Problem:

while rotate to landscape some view on top shown because i had added one custom view for status bar.How to avoid that?


Solution:

First you have to set the tag to the view that you are added for customisation.

Then follow the code.


    override open func viewDidLayoutSubviews() {

        super.viewDidLayoutSubviews()

        

       if let statusView = self.view.viewWithTag(9999) {

           statusView.isHidden = UIDevice.current.orientation.isLandscape

        }

    }

    override var prefersStatusBarHiddenBool {

        return UIDevice.current.orientation.isLandscape

    }


You can hide the view while from landscape then if it rotated to portrait it will automatically shown.

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift