Giter Site home page Giter Site logo

fittedsheets's Introduction

FittedSheets

Bottom sheets for iOS

Demo

About

This project is to enable easily presenting view controllers in a bottom sheet that supports scrollviews and multiple sizes. Contributions and feedback are very welcome.

Usage

Using a bottom sheet is simple.

The constructor is init(controller:, sizes:). Sizes is optional, but if specified, the first size in the array will determine the initial size of the sheet.

Using default settings

let controller = MyViewController()

let sheetController = SheetViewController(controller: controller)

self.present(controller, animated: false, completion: nil)

Customizing settings

let controller = MyViewController()

let sheetController = SheetViewController(controller: controller, sizes: [.fixed(100), .fixed(200), .halfScreen, .fullScreen)
sheetController.blurBottomSafeArea = false
sheetController.adjustForBottomSafeArea = true

self.present(controller, animated: false, completion: nil)

Settings

/// Determines if we should inset the view controller to account for the bottom safe area.
/// If your view controller already handles this, leave it false (the default)
/// If your view controller does *not* handle this, set it to true
var adjustForBottomSafeArea: Bool = false
/// Determines if we blur the contents under the bottom safe area (if there is a safe area)
/// The default value is true
var blurBottomSafeArea: Bool = true
/// The color of the overlay above the sheet.
var overlayColor: UIColor = UIColor(white: 0, alpha: 0.7)
/// Sets the heights the sheets will try to stick to. It will not resize the current size, but will affect all future resizing of the sheet.
func setSizes(_ sizes: [SheetSize])
/// This should be called by any child view controller that expects the sheet to use be able to expand/collapse when the scroll view is at the top.
func handleScrollView(_ scrollView: UIScrollView)

There is an extension on UIViewController that gives you a sheetViewController that attempts to find the current SheetViewController so you can attach like this:

override func viewDidLoad() {
  super.viewDidLoad()
  
  self.sheetViewController?.handleScrollView(self.scrollView) // or tableView/collectionView/etc
}

Cocoapods

The easiest way to integrate the project is through cocoapods.
Add this to your podfile to add FittedSheets to your project.

pod 'FittedSheets'

License

FittedSheets uses the MIT License:

Please see included LICENSE file.

fittedsheets's People

Contributors

gordontucker avatar dmillerconsulting avatar

Watchers

James Cloos avatar Kristoff IBell avatar

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.