8000 GitHub - sekies/YSCheckBox: Simple CheckBox for iOS
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

sekies/YSCheckBox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
< 8000 div class="Skeleton Skeleton--text"> 
 
 
 
 

Repository files navigation

YSCheckBox

YSCheckBoxは簡単に使えるiOS用のswift製チェックボックスライブラリです。

checkbox1  checkbox2  checkbox3 

Features

ブラウザ標準のようなチェックボックスです。

Installation

CocoaPods

  1. Podfileに pod 'YSCheckBox', :git => 'https://github.com/sekies/YSCheckBox.git' と追加します。
  2. pod install します。

Usage

  1. YSCheckBoxをインポートします。
import YSCheckBox
  1. 任意のUIViewContorollerでYSCheckBoxViewControllerDelegate プロトコルに準拠します。
class ViewController: UIViewController,YSCheckBoxViewControllerDelegate {
  1. YSCheckBoxViewControllerインスタンスを生成します。生成時にチェックボックスのラベルを配列で指定します。
let checkBox = YSCheckBoxViewController(labels: ["Orange","GrapeFruits","Banana"])
  1. delegateと各種デザインプロパティを設定します。必須となるのはdelegateのみです。
checkBox.delegate = self
checkBox.font = UIFont.systemFont(ofSize: 18)
checkBox.labelColor = UIColor(red: 0, green: 122 / 255, blue: 1, alpha: 1)
checkBox.labelMargin = 0
checkBox.lineWidth = 1
checkBox.checkBoxSelectedFillSize = 1
checkBox.checkBoxMargin = 6
checkBox.checkBoxCorner = 7
checkBox.checkBoxStroke = .lightGray
checkBox.checkBoxCheckStroke = .white
checkBox.checkBoxSelectedFill = UIColor(red: 0, green: 122 / 255, blue: 1, alpha: 1)
checkBox.checkBoxBGFill = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1)
  1. 親UIViewControllerに生成したYSCheckBoxViewControllerをaddChildしコンテナとなるUIViewにYSCheckBoxViewControllerのviewをaddSubviewします。チェックボックスの位置はコンテナとなるUIViewに依存します。
addChild(checkBox)
checkBox.view.frame = container.bounds
container.addSubview(checkBox.view)
checkBox.didMove(toParent: self)
  1. デリゲートメソッドを実装します。チェックボタンを選択するとこのメソッドが呼ばれます。YSCheckBoxViewController生成時に追加した配列の順にBoolが割り振られます。
func didYSCeckBoxSelect(checks: [Bool]) {
    print(checks)
}

About

Simple CheckBox for iOS

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0