Skip to content

πŸ„β€β™€οΈ A UIStackView, which scrolls.

License

Notifications You must be signed in to change notification settings

jdisho/ScrollableStackView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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

About

πŸ„β€β™€οΈ A UIStackView, which scrolls.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages