Giter Club home page Giter Club logo

button_custom's Introduction

Button_Custom

Swift 自定义 Button,多种图文布局,链式调用 Handler

// 图片和标题 间距
button.spacing = 10

button.set(title: "普通", state: .normal)
button.set(image: UIImage.add, state: .normal)

button.set(title: "高亮", state: .highlighted)
button.set(image: UIImage.add.alpha(0.6), state: .highlighted)
button.set(titleColor: UIColor.black.withAlphaComponent(0.3), state: .highlighted)

button.set(title: "选中", state: .selected)
button.set(titleColor: .red, state: .selected)

button.set(title: "禁用", state: .disabled)
button.set(titleColor: .systemBlue, state: .disabled)

button.hm_touchDown(action: { (_) in
    print("按下控件")
}).hm_touchUpInside { (_) in
    print("按下控件 控件内部松手")
}.hm_touchUpOutside { (_) in
    print("按下控件 控件外部松手")
}.hm_touchDownRepeat { (_) in
    print("重复按下控件")
}.hm_touchDragInside { (_) in
    print("手指首次触摸控件内部 在控件内部进行拖动")
}.hm_touchDragOutside { (_) in
    print("手指首次触摸控件外部 在控件外部进行拖动")
}.hm_touchDragEnter { (_) in
    print("手指首次触摸控件外部 拖动到控件内部")
}.hm_touchDragExit { (_) in
    print("手指首次触摸控件内部 拖动到控件外部")
}.hm_touchCancel { (_) in
    print("所有触摸事件取消")
}

button_custom's People

Contributors

uclort avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.