A SwiftUI ScrollView that only scrolls if the content doesn't fit in the View

Overview

ScrollViewIfNeeded

A SwiftUI ScrollView that only scrolls if the content doesn't fit in the View

Installation

Requirements iOS 13+

Swift Package Manager

  1. In Xcode, open your project and navigate to File → Swift Packages → Add Package Dependency.
  2. Paste the repository URL (https://github.com/dkk/ScrollViewIfNeeded) and click Next.
  3. For Rules, select version.
  4. Click Finish.

Add as dependency to another package

.package(url: "https://github.com/dkk/ScrollViewIfNeeded", .upToNextMajor(from: "1.0.0"))

Manual installation

Copy /Sources/ScrollViewIfNeeded/ScrollViewIfNeeded.swift into your project

Usage

Import the ScrollViewIfNeeded package to your view:

import ScrollViewIfNeeded

use it like you would use ScrollView:

ScrollViewIfNeeded {
    /* your content */
}

or configure it the same way you would configure ScrollView:

ScrollViewIfNeeded(.horizontal, showsIndicators: false) {
    /* your content */
}

Contribute

You can contribute to this project by helping me solve any reported issues or feature requests and creating a pull request.

Support

If you just want to say thanks, you could buy me a coffee ☕️ .

License

ScrollViewIfNeeded is released under the MIT License.

You might also like...
Placeholder views based on content, loading, error or empty states
Placeholder views based on content, loading, error or empty states

StatefulViewController A protocol to enable UIViewControllers or UIViews to present placeholder views based on content, loading, error or empty states

A paging scroll view for SwiftUI, using internal SwiftUI components
A paging scroll view for SwiftUI, using internal SwiftUI components

PagingView A paging scroll view for SwiftUI, using internal SwiftUI components. This is basically the same as TabView in the paging mode with the inde

SwiftUI-Margin adds a margin() viewModifier to a SwiftUI view.

SwiftUI-Margin adds a margin() viewModifier to a SwiftUI view. You will be able to layout the margins in a CSS/Flutter-like.

A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.

BadgeHub A way to quickly add a notification badge icon to any view. Demo/Example For demo: $ pod try BadgeHub To run the example project, clone the r

Confetti View lets you create a magnificent confetti view in your app
Confetti View lets you create a magnificent confetti view in your app

ConfettiView Confetti View lets you create a magnificent confetti view in your app. This was inspired by House Party app's login screen. Written in Sw

Advanced List View for SwiftUI with pagination & different states

AdvancedList This package provides a wrapper view around the SwiftUI List view which adds pagination (through my ListPagination package) and an empty,

📖   A lightweight, paging view solution for SwiftUI
📖 A lightweight, paging view solution for SwiftUI

Getting Started | Customization | Installation Getting Started Basic usage Using Pages is as easy as: import Pages struct WelcomeView: View { @S

🚀  Elegant Pager View fully written in pure SwiftUI.
🚀 Elegant Pager View fully written in pure SwiftUI.

PagerTabStripView Made with ❤️ by Xmartlabs team. XLPagerTabStrip for SwiftUI! Introduction PagerTabStripView is the first pager view built in pure Sw

A set of UIKit helpers that simplify the usage of UIKit view's and controller's in SwiftUI.

A set of UIKit helpers that simplify the usage of UIKit view's and controller's in SwiftUI. Many of these helpers are useful even in a pure UIKit project.

Comments
  • Add frame modifier to scroll view content

    Add frame modifier to scroll view content

    Add min width and height to mimic the layout behavior of when the content is not wrapped in a ScrollView.

    1. Centers the content when it is smaller than the scroll view container. This makes the ScrollView more transparent when it's not scrollable.
    2. Fixes a bug where the content would not become scrollable when the content size would increase due to a change in dynamic text size. (Cmd-Option-+ in the Simulator)

    Not sure about number 2. I've seen an instance where the old behavior persisted.

    opened by benlenarts 1
Releases(1.0.1)
Owner
Daniel Klöck
Senior software developer (iOS / AI / DevOps)
Daniel Klöck
DGFadingLabel - A custom UILabel that fades away the end of your text when text is too large to fit within the label's frame

A custom UILabel that fades away the end of your text when text is too large to fit within the label's frame.

donggyu 4 Jun 10, 2022
You can dismiss modal viewcontroller like Facebook Messenger by pulling scrollview or navigationbar in Swift.

PullToDismiss PullToDismiss provides dismiss modal viewcontroller function like Facebook Messenger by pulling scrollview or navigationbar with smooth

Suguru Kishimoto 479 Dec 5, 2022
ScrollView that supports a parallax header image and static overlay.

ScrollViewReactiveHeader A replacement ScrollView that provides a header with subtle scroll animations. example-video.mov Using ScrollViewReactiveHead

null 49 Dec 29, 2022
A SwiftUI Library for creating resizable partitions for View Content.

Partition Kit Recently Featured In Top 10 Trending Android and iOS Libraries in October and in 5 iOS libraries to enhance your app! What is PartitionK

Kieran Brown 230 Oct 27, 2022
SwiftUI view enabling navigation between pages of content, imitating the behaviour of UIPageViewController for iOS and watchOS

PageView SwiftUI view enabling page-based navigation, imitating the behaviour of UIPageViewController in iOS. Why SwiftUI doesn't have any kind of pag

Kacper Rączy 365 Dec 29, 2022
This Project is extremely useful for beginners who want to learn only SwiftUI.

This Project is extremely useful for beginners who want to learn only SwiftUI.In this project have used navigation between views, SignIn page view, Sign Up page view, Tab Bar view,

Jumman 0 Dec 31, 2021
A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView and iPhone X safe area support for content reloading. Built for iOS 10 and later.

Arale A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView support for reloading your content. Built f

Putra Z. 43 Feb 4, 2022
A controller that uses a UIStackView and view controller composition to display content in a list

StackViewController Overview StackViewController is a Swift framework that simplifies the process of building forms and other static content using UIS

Seed 867 Dec 27, 2022
A nice iOS View Capture Swift Library which can capture all content.

SwViewCapture A nice iOS View Capture Library which can capture all content. SwViewCapture could convert all content of UIWebView to a UIImage. 一个用起来还

Xing Chen 597 Nov 22, 2022