Giter Club home page Giter Club logo

scrollablestackview's Introduction

ScrollableStackView

A simple class that leverages the power of Auto Layout to make UIStackView scrollable.

  • πŸ“š Acts as a normal UIStackView, but scrollable.
  • πŸ“– Subclassed from UIScrollView and uses UIStackView under the hood.
  • πŸ‘Ά Easy-to-understand codebase (~ 100 lines of code)
  • πŸŽ‰ No external dependencies.

βš™οΈ Installation

Download ScrollableStackView and manually import the file into your project.

πŸ“š Usage

  • Initializing
  let stackView = ScrollableStackView(frame: CGRect)
  // or
  let stackView = ScrollabelStackView(arrangedSubviews: [UIView]) // returns a new stack view object that manages the provided views
  • Manage arranged subviews
 var arrangedSubviews: [UIView] // list of views arranged by the stack view
 
 func addArrangedSubview(UIView) // adds *a view* to the end of the arrangedSubviews

 func addArrangedSubviews([UIView]) // adds *views* to the end of the arrangedSubviews
 
 func insertArrangedSubview(UIView, at: Int) // adds the provided view to the array of arranged subviews at the specified index
 
 func removeArrangedSubview(UIView) // removes the provided *view* from the stack’s array of arranged subviews
 
 func removeArrangedSubviews([UIView]) // removes the provided *views* from the stack’s array of arranged subviews
 
  • Configure the layout
  var axis: NSLayoutConstraint.Axis // default .horizontal
   
  var distribution: UIStackView.Distribution // default .fill
  
  var aligment: UIStackView.Distribution // default .fill
  
  var spacing: CGFloat // default 0.0
  
  var insets: UIEdgeInsets // default .zero

I intent to keep this code base as simple as possible. Just as normal UIStackView, which scrolls. If you are interested in a scrollable UIStackView on steroids, check out AloeStackView by Airbnb.

πŸ™ Acknowledgements

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.