Giter VIP home page Giter VIP logo

Comments (3)

vadimue avatar vadimue commented on July 19, 2024 1

@Isuru-Nanayakkara hey guys,

You don't need to change source code of the library. You just need to change automaticallyAdjustsScrollViewInsets of UIViewController to false

from swiftyonboard.

Nexmind avatar Nexmind commented on July 19, 2024

Quick win solution

Solved by adding the height of the navigationBar in the height of containerView in the setupContainerView method in SwiftyOnBoard class.

    if navigationBarIsPresent {
            var newFrame = frame
            newFrame.size.height = frame.height + 64
            self.containerView.frame = newFrame
    } else {
            self.containerView.frame = frame
    }

declaration

    open var navigationBarIsPresent: Bool = false

set

    self.swiftOnBoard.navigationBarIsPresent = true
    self.swiftOnBoard.delegate = self
    self.swiftOnBoard.dataSource = self

from swiftyonboard.

Isuru-Nanayakkara avatar Isuru-Nanayakkara commented on July 19, 2024

Thanks @Nexmind. I was experiencing this issue as well. I took your solution and expanded on it a little. Instead of hardcoding the navigation bar height and adding an extra property, I added the following extension method to retrieve the parent view controller in which this view is displayed.

private extension UIView {
    var parentController: UIViewController? {
        var parentResponder: UIResponder? = self
        while parentResponder != nil {
            parentResponder = parentResponder!.next
            if let viewController = parentResponder as? UIViewController {
                return viewController
            }
        }
        return nil
    }
}

After that in the setupContainerView method, I simply check if the parent view controller has a navigation controller and get its navigation bar's height this way.

if let navigationBar = self.parentController?.navigationController?.navigationBar {
    var newFrame = self.frame
    newFrame.size.height = self.frame.height + navigationBar.frame.height
    self.containerView.frame = newFrame
} else {
    self.containerView.frame = self.frame
}

Created a PR #25. If it doesn't get merged, you can still add the following to your Podfile if you're using CocoaPods.

pod 'SwiftyOnboard', :git => 'https://github.com/Isuru-Nanayakkara/SwiftyOnboard.git', :branch => 'navbar-fix'

from swiftyonboard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.