Skip to content

Checkbox tree for iOS, easy-to-use and customizable.

License

Notifications You must be signed in to change notification settings

aporohov/APCheckboxTree

Repository files navigation

APCheckboxTree

Language Platform CocoaPods Compatible GitHub license

Easy-to-use library to build checkbox tree out of plain item models. Fully customizable.

TreeDemo CustomViews

Requirements

  • Swift 5
  • iOS >= 13.0

Installation

  1. File > Swift Packages > Add Package Dependency
  2. Copy & paste this line then follow the instruction
https://github.com/aporohov/APCheckboxTree.git

Add this line to your Podfile and run pod install

pod 'APCheckboxTree'

Usage

Configure tree view

// Create instance of tree view

let tree = APCheckboxTree()

// Setup items of checkbox tree

tree.items = [
    APCheckboxItem(title: "Fruits",
                   children: [
                    APCheckboxItem(title: "Orange"),
                    APCheckboxItem(title: "Apple",
                                   isSelected: true)
                   ])
]

// Add tree on the superview then ...

APCheckboxTreeDelegate

extension MyViewController: APCheckboxTreeDelegate {
    func checkboxItemDidSelected(item: APCheckboxItem) {
        print(item)
    }
}

Customize style

Tree style

// Disable items group open/close animation

tree.style.isCollapseAnimated = false

// Make tree items always visible

tree.style.isCollapseAvailable = false

Icons

tree.style.images.checkboxOn = UIImage(named: "icCheckboxOn")
tree.style.images.checkboxOff = UIImage(named: "icCheckboxOff")

Fonts / Colors / Layout

tree.style.itemViewStyle.titleFont = .systemFont(ofSize: 16)
tree.style.itemViewStyle.minHeight = 54
tree.style.itemViewStyle.titleColor = .darkGray