StickyFooterScrollView is developed for quick creation of UIScrollView to implement. Usually when creating UIScrollView, developers have to declare and adjust many complex UI constraints to use, StickyFooterScrollView was developed to solve the above problem. StickyFooterScrollView focuses on quick initialization of UIScrollView and its ease of use with a few declared simple functions
To run the example project, clone the repo, and run pod install
from the Example directory first.
StickyFooterScrollView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'StickyFooterScrollView'
import StickyFooterScrollView
- Initiate
StickyFooterScrollView
let scrollView = StickyFooterScrollView(minimumFooterTopOffset: 24)
- Add
StickyFooterScrollView
into parent
view.addSubview(scrollView)
- Setup constraints for
StickyFooterScrollView
scrollView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
scrollView.topAnchor.constraint(equalTo: view.topAnchor),
scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
scrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
scrollView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
])
- Setup content view and add into
StickyFooterScrollView
to display the main content
let mainContentView = UIStackView()
mainContentView.axis = .vertical
let imageView = UIImageView(image: UIImage(named: "Image"))
mainContentView.addArrangedSubview(imageView)
let titleLabel = UILabel()
titleLabel.text = "Hello"
titleLabel.textColor = .red
mainContentView.addArrangedSubview(titleLabel)
let descriptionLabel = UILabel()
descriptionLabel.text = "Sticky Footer Scroll View"
descriptionLabel.textColor = .blue
mainContentView.addArrangedSubview(descriptionLabel)
scrollView.applyContentView(mainContentView, with: .init(top: 24, left: 24, bottom: 24, right: 24))
- Setup the footer view and add into
StickyFooterScrollView
to display the footer content
let confirmButton = UIButton()
confirmButton.setTitle("OK", for: .normal)
scrollView.applyFooterView(confirmButton, with: .init(top: 24, left: 24, bottom: 24, right: 24))
- On function
viewDidAppear
, call the functionupdateLayout
for constraint UI
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
contentView.scrollView.updateLayout()
}
fanta1ty, [email protected]
StickyFooterScrollView is available under the MIT license. See the LICENSE file for more info.