Skip to content

urlaunched-com/MFNavigationBarAppearing

Repository files navigation

MFNavigationBarAppearing

Author Version iOS 9.0+ Xcode 10.0 Swift 4.2 License

"the app is developed by You are launched"

Requirements

  • Xcode 10+
  • iOS 9.0+
  • Swift 4.2

Example

Open and run the MFNavigationBarAppearing.xcodeproj in Xcode to see example

Installation

CocoaPods

source "https://github.com/Molfar-io/MFPodSpecs.git"

pod 'MFNavigationBarAppearing'

Manual

Add MFNavigationBarAppearing/Code folder into your project.

Usage

First of all you need to setup content insets of your scroll view

Content insets

Important

You need to use MFNavigationBarAppearingController instead of UINavigationContoller for presenting your UIViewController. This UIViewController should implement MFNavigationBarAppearer protocol

let navigationController = MFNavigationBarAppearingController(rootViewController: UIViewController<MFNavigationBarAppearer>())
present(navigationController, animated: true, completion: nil)

Next step is implement MFNavigationBarAppearer protocol in your UIViewController:

import MFNavigationBarAppearing

//MARK: - MFNavigationBarAppearer
extension UIViewController: MFNavigationBarAppearer {
    
    var appearingScrollView: UIScrollView? {
        return scrollView
    }

    var navigationBarStartAppearingOffset: CGFloat {
        return collectionViewContainer.frame.height - collectionViewBottomSpacing
    }
    
    var navigationBarEndAppearingOffset: CGFloat? {
        return collectionViewContainer.frame.height
    }
    
    var appearingTitle: String? {
        return place.title?.uppercased()
    }
    
    var appearingTitleStartOffsetAfterAppearingNavBar: CGFloat? {
        return collectionViewContainer.frame.height + titleLabelTopSpacing
    }
    
    var appearingTitleEndOffsetAfterAppearingNavBar: CGFloat? {
        return collectionViewContainer.frame.height + placeTitleLabel.frame.height
    }
}

appearingScrollView

It's UIScrollView which we will use to handle content offset for calculating appearing state of the navigation bar.

navigationBarStartAppearingOffset

The offset from the top of the screen, when you need to start navigation bar appearing.

navigationBarEndAppearingOffset (Optional)

The offset when navigation bar appearing should end. If the value is not provided, it will be calculated depending on the height of the navigation bar.

appearingTitle (Optional)

The title that will be appearing interactively.

appearingTitleStartOffsetAfterAppearingNavBar (Optional)

The offset (delay in pixels) befor starting title appearing. 0 by default.

appearingTitleEndOffsetAfterAppearingNavBar (Optional)

The offset when navigation bar appearing should be finish. By default title will be appeared together with navigation bar.

Contacts

If you have any questions regarding pod usage or any improvements ideas, just contact me by email mx.kuznetsov.dev@gmail.com

P.S. If you have ideas for this pod, but don't have time to implement it - write us your idea and we will do it.

Our resources

Official website
Our company timeline
You are launched expertise
You are launched iOS expertise
You are launched Android expertise
You are launched design expertise
You are launched web expertise
You are launched Lean Startup expertise
You are launched successful startups
Official blog

License

The MIT License (MIT)

Copyright © 2018 Max Kuznetsov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.