Need help with Arranged?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

kean
201 Stars 17 Forks MIT License 120 Commits 0 Opened issues

Description

Open source replacement of UIStackView for iOS 8 (100% layouts supported)

Services available

!
?

Need anything else?

Contributors list

Arranged.StackView

Open source replacement of UIStackView for iOS 8 (100% layouts supported)

Deprecated. UIStackView was introduces in iOS 9, please use the native one.

  • Supports all
    alignments
    and
    distributions
    ,
    spacing
    ,
    baselineRelativeArrangement
    ,
    layoutMarginsRelativeArrangement
    ,
    axis
  • Unit tested, thousands of layouts covered
  • Supports animations
  • Generates exactly the same sets of constraints as
    UIStackView
    :

UIStackView (

Alignment.Leading
,
Distribution.FillEqually
)




= content-view-1.bottom>

= content-view-2.bottom>

Arranged (

Alignment.Leading
,
Distribution.FillEqually
)




= content-view-1.bottom>

= content-view-2.bottom>

Usage

Arranged.StackView
is used the same way
UIStackView
is:
let stackView = StackView(arrangedSubviews: [view1, view2, view3])
stackView.alignment = .leading
stackView.distribution = .fillEqually
stackView.spacing = 20
stackView.axis = .vertical
stackView.isLayoutMarginsRelativeArrangement = true

The only difference is hiding items:

UIView.animateWithDuration(0.33) {
    stackView.setArrangedView(view, hidden: true)
    stackView.layoutIfNeeded()
}

Requirements

  • iOS 8.0, tvOS 9.0
  • Xcode 9
  • Swift 4

Getting Started

  • Get a demo project using
    pod try Arranged
    command
  • Install,
    import Arranged
    and enjoy!

Differences

  • UIStackView
    observes
    hidden
    property of arranged views, delays its effect if called inside animation block, and updates constraints accordingly. I believe this behavior is confusing and impractical to implement.
    Arranged.StackView
    provides a straightforward method
    setArrangedView(_:hidden:)
    which updates constraints exactly the same way as
    UIStackView
    does, but it doesn't affect
    hidden
    property.
  • Animations require you to call
    view.layoutIfNeeded()
    - just like with any regular layout
  • StackViewDistribution.FillProportionally
    doesn't update its constrains when
    intrinsicContentSize
    of arranged views changes due to the fact that
    UIStackView
    uses private API (
    _intrinsicContentSizeInvalidatedForChildView
    ) to achieve that
  • UISV-text-width-disambiguation
    constraints are not implemented because they are not documented (and you probably should disambiguate text views the way that fits your app anyway)

Installation

CocoaPods

To install Arranged add a dependency to your Podfile:

# source 'https://github.com/CocoaPods/Specs.git'
# use_frameworks!
# platform :ios, "8.0"

pod "Arranged"

Carthage

To install Arranged add a dependency to your Cartfile:

github "kean/Arranged"

Import

Import installed modules in your source files

import Arranged

License

Arranged is available under the MIT license. See the LICENSE file for more info.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.