Skip to content

zhenghongyi/YITokenField

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iOS上的TokenField控件,具有

  1. 可自定义token和对应token视图
  2. 可通过键盘删除所选token
  3. 可添加尾部视图
  4. 可拖动token视图来调整顺序

使用示例

let tokenField = YITokenField()
tokenField.placeholder = "请输入"
// tail
tokenField.tailView = importButton
tokenField.tailWidth = 30
tokenField.register(CustomTokenView.self)
tokenField.delegate = self
view.addSubview(tokenField)
// 设置约束或frame
tokenField.appendTokens([CustomToken(text: "123")])
......
// MARK: YITokenFieldDelegate
func tokenFieldShouldReturn(_ tokenField: YITokenField) -> Bool {
    if let text = tokenField.text {
        tokenField.appendTokens([CustomToken(text: text)])
        tokenField.text = nil
    }
    return true
}

func tokenFieldDidChangeHeight(_ tokenField: YITokenField, newHeight: CGFloat) {
    // 更新tokenField高度
}

img

About

iOS上的TokenField

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages