Showing posts with label iOS 11. Show all posts
Showing posts with label iOS 11. Show all posts

Monday, April 30, 2018

Hide indicator lines from UIPickerView


Hello Everyone,

         Today I am going show you how to remove selection indicator lines from UIPickerView . This is very simple. Before we start on the process to remove indicator lines, let’s understand the hierarchy of views layer in UIPickerView.
UIPickerView contains subviews to draw two indicator lines to display the current selection.


Step 1: I am assuming that you have UIPickerView setup already done. And currently displays like below screenshot.





Step 2: Magic begins here.
Ø  Add viewDidLayoutSubviews method on current view controller.
Ø  After that add below code into that method.
          for i in [1, 2] {
            optionsPickerView.subviews[i].isHidden = true
           }



Step 3: At last  viewDidLayoutSubviews  method will be like below.
        
         override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        for i in [1, 2] {
            optionsPickerView.subviews[i].isHidden = true
        }
    }





Step 4: Relaunch application with above changes applied to the view controller and UIPickerView will not display indicator lines.
Output will be like below screenshot.






Happy Coding!! Thank You!!
   

Thursday, October 5, 2017

UIScrollView, TableView Underlapping Navigation Bar iOS 11




Hi Friends,

               Many of us are facing issue with their iOS apps on iOS 11 like "scrollview/table view is underlapping Navigation Bar". Today I am going to provide a quick solution to make your iOS app working properly on iOS 11 if you are facing above mentioned issue.

On iOS 11 apple has added new property for scroll view i.e. contentInsetAdjustmentBehaviour.

So your app can be fixed by adding this property and set to UIScrollViewContentInsetAdjustmentBehavior.never.

or add code to your scrollview given below.
if #available(iOS 11.0, *) {
    myScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.never

}

 Hope this will help you to fix your issue with app. And your app will work as it was working on earlier iOS version.

                                                                                      
                                                                                              Thanks.

Leave a question/ comment if needed.