• Stars
    star
    188
  • Rank 205,563 (Top 5 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 2 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A lightweight, fully interactive split-screen sheet.

SplitSheet

Header Image

A lightweight, fully interactive split-screen sheet.

  • Powered by UIScrollView for super-smooth gestures.
  • Show/hide either programmatically or with a swipe gesture.
  • Gestures are fully interruptible.
  • Won't affect buttons and gestures nested in subviews.
  • Supports sizing detents (hidden, shown, expanded).
  • Fully compatible with Auto Layout self-sizing.
  • Super simple, no dependencies, ~300 lines of code.
  • Replicates iOS 15's sheet detents while supporting iOS 9+.

Showcase

Click to show sheet Swipe between sheet detents Overlay the sheet without displacing main content

Installation

Requires iOS 9+. SplitSheet can be installed through the Swift Package Manager (recommended) or manually.

Swift Package Manager
Add the Package URL:
Manual
Drag this file into your project:

https://github.com/aheze/SplitSheet

Sources/SplitSheet.swift

Usage

import Combine
import SplitSheet
import UIKit

class ViewController: UIViewController {

    /// Works with any view controller.
    let mainViewController = MainViewController()
    let sheetViewController = SheetViewController()
    lazy var splitSheetController = SplitSheetController(
        mainViewController: mainViewController,
        sheetViewController: sheetViewController
    )

    override func viewDidLoad() {
        super.viewDidLoad()

        /// If true, `mainViewController` will shift up as the sheet is shown.
        splitSheetController.displaceContent = true

        /// Show a grabber handle.
        splitSheetController.showHandle = true

        /// The minimum sheet height.
        splitSheetController.minimumSheetHeight = CGFloat(400)

        /// When the sheet is shown and dragged within this limit, the sheet will bounce back.
        splitSheetController.snappingDistance = CGFloat(150)

        /// How long the show/hide animation takes.
        splitSheetController.animationDuration = CGFloat(0.6)

        /// If swiping up to show the sheet is allowed or not.
        splitSheetController.swipeUpToShowAllowed = true

        /// Override the status bar color.
        splitSheetController.statusBarStyle = UIStatusBarStyle.default
        
        /// Add the sheet.
        embed(splitSheetController, inside: view)
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        /// Show the sheet programmatically.
        splitSheetController.show(true)
    }

    /// Propagate `splitSheetController`'s custom status bar to this view controller.
    override var childForStatusBarStyle: UIViewController? {
        return splitSheetController
    }
}

Self-Sizing and Detents

It's simple β€” if your sheet view controller's intrinsic size is larger than the minimumSheetHeight, a "large" detent will be added.

class SheetViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.backgroundColor = .systemTeal
        view.heightAnchor.constraint(equalToConstant: 800).isActive = true
    }
}

Hidden, shown, and expanded modes.

Author Contributing Need Help?
SplitSheet is made by aheze. All contributions are welcome. Just fork the repo, then make a pull request. Open an issue or join the Discord server. You can also ping me on Twitter. Or read the source code β€” there's lots of comments.

Apps Using SplitSheet

Find is an app for finding your photos. SplitSheet is used for the photo gallery view and info sheet β€” download to check it out!

Find App

If you have an app that uses SplitSheet, just make a PR or message me.

License

MIT License

Copyright (c) 2022 A. Zheng

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.

More Repositories

1

Popovers

A library to present popovers. Simple, modern, and highly customizable. Not boring!
Swift
1,944
star
2

Setting

Compose beautiful preference panels.
Swift
1,429
star
3

SwipeActions

Add customizable swipe actions to any view.
Swift
1,016
star
4

OpenFind

An app to find text in real life.
Swift
983
star
5

Prism

A lightweight 3D renderer for SwiftUI.
Swift
923
star
6

Multiliner

An Xcode source extension to expand lengthy lines.
Swift
829
star
7

Squirrel

Enable scrolling in the Xcode Simulator!
Swift
620
star
8

VariableBlurView

A one-file, App Store upload-safe version of Janum Trivedi's variable blur effect.
Swift
372
star
9

SwiftUICraft

Minecraft but made with SwiftUI.
Swift
303
star
10

RealityKitLaunchScreen

A launch screen made with SwiftUI and RealityKit. Used in the Find app.
Swift
239
star
11

SupportDocs

Generate help centers for your iOS apps. Hosted by GitHub and always up-to-date.
Swift
161
star
12

ProgressGif

Add progress bars to gifs!
Swift
105
star
13

AppClipQuickStart

Make an app clip.
Swift
50
star
14

implicit-curves

Graph implicit curves in Swift
Swift
30
star
15

AccessibleReality

[Accepted] My WWDC21 Swift Student Challenge submission.
Swift
26
star
16

AlternativeARKit

A custom alternative to ARKit
Swift
22
star
17

PathMapper

Find the shortest distance between 2 points on a map!
Swift
19
star
18

StitchCounter

An app to count stitches in crochet patterns. Multiplatform.
Swift
19
star
19

MarkdownTextEditor

Markdown editor in SwiftUI 3
Swift
18
star
20

CustomSCNGeometry

How to make a custom SCNGeometry
Swift
17
star
21

ClassX

Swift
15
star
22

Missions

Missions for Midnight
Swift
13
star
23

QuickOCR

Drag-and-drop to find text. A work in progress.
Swift
12
star
24

ConnectFour

Literally just Connect 4 in SwiftUI
Swift
10
star
25

AnimateBetweenCollectionLayouts

Animate from "horizontal film strip" to "Vertical/expanded stack"
Swift
10
star
26

aheze

8
star
27

SixDegrees

Swift
8
star
28

MetalGradient

Swift
8
star
29

Projector

Forget the Simulator β€” swap your aspect ratio instead!
Swift
7
star
30

Buildings

Building block app made with SwiftUI
Swift
6
star
31

CalHacks

Swift
5
star
32

AcuteCalculator

Support files for Acute Calculator
5
star
33

ARKitCube

Demo app to render a cube with ARKit and SceneKit.
Swift
5
star
34

BarcodeScanner

Swift
3
star
35

ProjectorExample

Test out your app on different device sizes
Swift
3
star
36

VidQuery

CodeDay - Most Likely to Use winner
Swift
3
star
37

OpenFind-SupportDocs

Help center and other resources for Find app
Swift
3
star
38

TableViewReverseAnimation

Swift
3
star
39

PhotoLoadingTest

Swift
3
star
40

FastAssets

Testing to get photo assets quickly
Swift
2
star
41

SampleApp

A sample app for all purposes. Tap the squircle to spin it.
Swift
2
star
42

Find-Lists

Website for lists sharing in Find (getfind.app)
JavaScript
2
star
43

MyAppClipWebsite

Swift
2
star
44

StatusBarHide

Swift
2
star
45

Findbot

A Python bot. Check it out at https://getfind.app/discord
Python
2
star
46

DeveloperAssets

Just some images. Feel free to store yours here if you want.
Rich Text Format
2
star
47

FindHelp

Short tutorials/help docs for Find app. This is outdated, but I haven't gotten around to updating it
HTML
2
star
48

MyHelpCenter

Swift
2
star
49

FindAppSupport

Useful files that may be used in Find app
HTML
2
star
50

CardScanner

Swift
2
star
51

tdee-calculator

TypeScript
2
star
52

PlaygroundSync

Git for swift playgrounds, under development
Swift
1
star
53

Licenses

For hosting the licenses I use
1
star
54

schedules-ios

The iOS companion for Schedules
Swift
1
star
55

Assets

Just some file storage.
1
star
56

ReadmeTables

Tables don't need to be boring
1
star
57

LearningWebDev

Just learning web development, and following some tutorials! Testing on GitHub Pages.
HTML
1
star
58

SwiftUIImageTransitionTest

Swift
1
star
59

PhotoLoading

Memory issue
Swift
1
star
60

SwiftUISearchBar

Swift
1
star
61

SwiftUICamera

Swift
1
star
62

Find-Assets

Screenshots and other stuff for Find (getfind.app)
1
star
63

Medium

Support files for my Medium articles, but larger projects may have their own repository.
HTML
1
star
64

Find-Issues

Bug tracker for Find
1
star
65

TwoSetTableView

Swift
1
star
66

TargetContentOffsetTest

Demo repo for my question "UICollectionViewFlowLayout `targetContentOffset` - how to keep cells centered after orientation change?"
Swift
1
star
67

Find-Website-Old

Official website of Find app
CSS
1
star
68

TextFieldConstraintDemo

Demo repo for https://stackoverflow.com/questions/65928019/how-to-reduce-width-between-ui-components-in-my-case-uilabel-and-uitextfield
Swift
1
star