Monday, November 20, 2017

Increase bottom layout length/inset/padding

Leave a Comment
  1. Subclass UITabBarController
  2. Hide/remove original tab bar
  3. Put custom view to bottom of the UITabBarController view
  4. UITabBarController -> UIViewController -> UIScrollView (pinned to superview all edges, not layout, and set adjusts scroll view insets on vc to true)

Expected: UIScrollView's content is fully visible when I scroll to bottom of the scroll view

Actual: No inset applied and scrollview's content goes under my custom view.

As for iOS 11, additionalSafeAreaInsets is working as needed. But what can I do for iOS 10 & 9?

Overriding bottomLayoutGuide never called. Setting view.layoutMargins did not help

1 Answers

Answers 1

As I understand your problem you want to add bottom margin to your scrollView

class CustomTabBarController: UITabBarController {      var customView: UIView!      override func viewDidLoad() {         super.viewDidLoad()         self.viewControllers?.forEach { controller in             if let controller = controller as? CustomProtocol {                 controller.setBottomMargin(customView.frame.height)             }         }     } }  protocol CustomProtocol {     func setBottomMargin(_ margin: CGFloat) }  class ViewController: UIViewController, CustomProtocol {     @IBOutlet weak var scrollView: UIScrollView!     @IBOutlet weak var bottomMargin: NSLayoutConstraint!      func setBottomMargin(_ margin: CGFloat) {         self.bottomMargin.constant = margin     } } 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment