StickyFooterScrollView是为快速创建UIScrollView来实现而开发的
粘性页脚滚动视图
StickyFooterScrollView是为快速创建UIScrollView来实现而开发的。通常在创建UIScrollView时,开发人员必须声明和调整许多复杂的UI约束才能使用,StickyFooterScrollView就是为了解决上述问题而开发的。StickyFooterScrollView专注于UIScrollView的快速初始化及其易用性,并带有一些声明的简单函数
例
若要运行示例项目,请克隆存储库,然后首先从示例目录运行。pod install
要求
Installation
StickyFooterScrollView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'StickyFooterScrollView'
Usage
import StickyFooterScrollView
- Initiate
StickyFooterScrollView
let scrollView = StickyFooterScrollView(minimumFooterTopOffset: 24)
- Add into parent
StickyFooterScrollView
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 to display the main content
StickyFooterScrollView
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 to display the footer content
StickyFooterScrollView
let confirmButton = UIButton()
confirmButton.setTitle("OK", for: .normal)
scrollView.applyFooterView(confirmButton, with: .init(top: 24, left: 24, bottom: 24, right: 24))
- On function , call the function for constraint UI
viewDidAppear
updateLayout
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
contentView.scrollView.updateLayout()
}
Author
fanta1ty, thinhnguyen12389@gmail.com
License
StickyFooterScrollView is available under the MIT license. See the LICENSE file for more info.