StackScrollView
📋 iOS Form UI Builder in Swift (powered by UICollectionView)
Install / Use
/learn @FluidGroup/StackScrollViewREADME
StackScrollView
<img width=320 src="Resources/shot.png"><img width=320 src="Resources/sample.gif">
⚠️ This sample is using demo-components. StackScrollView does not have default-components. StackScrollView is like UIStackView. So, we need to create the components we need.
What is this?
StackScrollView builds form UI easily.
StackScrollView includes UICollectionView.
UICollectionView calculates size of view by AutoLayout, then that display.
(Use systemLayoutSizeFitting)
- We call
StackCellinstead ofCellon StackScrollView. - We no longer need to consider reusing Cells.
StackCellrequires constraint based layout.
Usage
Basic usage
let stack = StackScrollView()
stack.append(view: ...)
stack.remove(view: ..., animated: true)
APIs
StackScrollView
func append(view: UIView)
func remove(view: UIView, animated: Bool)
func scroll(to view: UIView, at position: UICollectionViewScrollPosition, animated: Bool)
StackCellType
StackScrollView does not required StackCellType.
if StackCell has StackCellType, be easy that control StackCell.
func scrollToSelf(animated: Bool)
func scrollToSelf(at position: UICollectionViewScrollPosition, animated: Bool)
func updateLayout(animated: Bool)
func remove()
Demo has included this APIs usage.
Create CustomCell from Code
We have to set constraints completely.
final class LabelStackCell: UIView {
private let label = UILabel()
init(title: String) {
super.init(frame: .zero)
addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false
label.topAnchor.constraint(greaterThanOrEqualTo: topAnchor, constant: 8).isActive = true
label.bottomAnchor.constraint(lessThanOrEqualTo: bottomAnchor, constant: 8).isActive = true
label.rightAnchor.constraint(equalTo: rightAnchor, constant: 8).isActive = true
label.leftAnchor.constraint(equalTo: leftAnchor, constant: 8).isActive = true
label.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
heightAnchor.constraint(greaterThanOrEqualToConstant: 40).isActive = true
label.font = UIFont.preferredFont(forTextStyle: .body)
label.text = title
}
}
let stack = StackScrollView()
stack.append(view: LabelStackCell(title: "Label"))
Create CustomCell from XIB
We can use UIView from XIB.
This framework has NibLoader<T: UIView>.
It might be useful for you.
Create everything
You can create any Cell.
Please, check StackScrollView-Demo
ManualLayout
You can create Cell with ManualLayout.
If you use ManualLayout, the Cell have to use ManualLayoutStackCellType.
Then, return self-size based on maximum size in size(maxWidth:maxHeight)
Author
muukii, muukii.app@gmail.com
License
StackScrollView is available under the MIT license. See the LICENSE file for more info.
Related Skills
node-connect
343.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
90.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
