Overlay ViewController in iOS with Swift 5

Overlay ViewController in iOS with Swift 5
July 1, 2020 No Comments Development,iOS Development Pushpendra Kumar

Hey, Guys welcome to this tutorial. In this complete video, I will make you understand about the quick trick that how you can Overlay ViewController. And this is a simple way to achieve our goals. By this small trick, you can make your iOS application more attractive and more function-able with the help of Overlay ViewController functionality. So watch the complete video. And if you watched the complete video then do not forget to give your suggestion. Because your feedback & suggestions does matter for me πŸ˜ŠπŸ˜ŠπŸ˜ŠπŸ˜ŠπŸ‘‡πŸ» And finally, I would like to say that, If you like this video and it’s helpful for your project then click on like button and do not forget to subscribe to this YouTube channel for future updates.

Great! Below is the useful code of this video.

Overlay ViewController

  1. Install Pod Library
  2. After installing pod in your code add the following library.
pod 'OverlayContainer'

After that assign the View controller as mentioned into the above video.
And finally write the following code in your viewDidLoad() Function

//
//  ViewController.swift
//  Overlay example
//
//  Created by Pushpendra on 01/07/20.
//  Copyright Β© 2020 Pushpendra. All rights reserved.
//

import UIKit
import OverlayContainer

class ViewController: OverlayContainerViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let story = UIStoryboard(name: "Main", bundle: nil)
        
        let mapController = story.instantiateViewController(identifier: "MapController") as!  MapController
        let detailController = story.instantiateViewController(identifier: "DetailsController") as! DetailsController
        
        self.viewControllers = [mapController, detailController]
        self.delegate = self
        
    }
}

extension ViewController : OverlayContainerViewControllerDelegate {
    func overlayContainerViewController(_ containerViewController: OverlayContainerViewController, heightForNotchAt index: Int, availableSpace: CGFloat) -> CGFloat {
        switch Notches.allCases[index] {
        case .minimum:
            return availableSpace * 1/5
        case .medium:
            return availableSpace/2
        case .maximum:
            return availableSpace * 3/4
        }
    }
    
    func numberOfNotches(in containerViewController: OverlayContainerViewController) -> Int {
        return Notches.allCases.count
    }
}

enum Notches : Int, CaseIterable {
    case minimum, medium, maximum
}

Good Job….!!!

In Conclusion, You have done with this tutorial. And hope now the concept of Overlay View Controller in iOS with Swift 5 is clear. If you have any doubts regarding the Overlay ViewController in iOS with Swift 5 then you can comment into the comment box. And if you like this tutorial with a complete description of the simple and attractive tutorial in iOS then pleaseΒ like my videoΒ on YouTube and do not forget to subscribe to myΒ YouTube channel. Because you will get lots of videos related to swift development with very sort tricks.

Besides, If you are more curious about the development and knowing about tutorials then follow the below links πŸ‘‡πŸ»πŸ‘‡πŸ»πŸ‘‡πŸ»πŸ˜Ž

Tags
About The Author
Pushpendra Kumar I am passionate about mobile application development and professional developer at Colour Moon Technologies Pvt Ltd (www.thecolourmoon.com). This website I have made so that I can meet with new challenges and can share here.

Leave a reply

Your email address will not be published. Required fields are marked *