StickyFooterScrollView是为快速创建UIScrollView来实现而开发的

商标

粘性页脚滚动视图

StickyFooterScrollView是为快速创建UIScrollView来实现而开发的。通常在创建UIScrollView时,开发人员必须声明和调整许多复杂的UI约束才能使用,StickyFooterScrollView就是为了解决上述问题而开发的。StickyFooterScrollView专注于UIScrollView的快速初始化及其易用性,并带有一些声明的简单函数

斯威夫特 5.0 版本 许可证 平台 电子邮件

若要运行示例项目,请克隆存储库,然后首先从示例目录运行。pod install

要求

Installation

StickyFooterScrollView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'StickyFooterScrollView'

Usage

import StickyFooterScrollView
  1. Initiate StickyFooterScrollView
let scrollView = StickyFooterScrollView(minimumFooterTopOffset: 24)
  1. Add into parentStickyFooterScrollView
view.addSubview(scrollView)
  1. 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)
])
  1. Setup content view and add into to display the main contentStickyFooterScrollView

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))
  1. Setup the footer view and add into to display the footer contentStickyFooterScrollView

let confirmButton = UIButton()
confirmButton.setTitle("OK", for: .normal)

scrollView.applyFooterView(confirmButton, with: .init(top: 24, left: 24, bottom: 24, right: 24))
  1. On function , call the function for constraint UIviewDidAppearupdateLayout

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

contentView.scrollView.updateLayout()
}

alt text

Author

fanta1ty, thinhnguyen12389@gmail.com

License

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

GitHub

点击跳转