Skip to content

malt03/OverlappingViewsSeparator

Repository files navigation

OverlappingViewsSeparator SwiftPM compatible CocoaPods License

Screenshot

Minimum Example

import UIKit
import OverlappingViewsSeparator

class ViewController: UIViewController {
    @IBOutlet private var overlappingViews: [UIView]!
    private let separator = OverlappingViewsSeparator(minSpacing: 8)
    
    override func viewDidLoad() {
        super.viewDidLoad()
        separator.register(views: overlappingViews)
    }

    @IBAction private func apply() {
        separator.separate()
    }
}

Installation

SwiftPM (Recommended)

  • On Xcode, click File > Swift Packages > Add Package Dependency...
  • Input https://github.com/malt03/OverlappingViewsSeparator.git
  • Insert pod 'OverlappingViewsSeparator' to your Podfile.
  • Run pod install.

Advanced Example

Separate with animation

separator.separate { (reflect) in
    UIView.animate(withDuration: 1) {
        reflect()
    }
}

Register stuck view

separator.register(stuckView: stuckView)

Reset

separator.reset()

Set queue

let separator = OverlappingViewsSeparator(queue: .main) // default: .global()