Giter Site home page Giter Site logo

cocoaslider's Introduction

CocoaSlider

macOS 对 NSSlider 的封装,支持单向/双向滑动及支持 SwiftUI 工程

support macOS:10.15 and after

AppKit

let slider2 = CocoaSlider(value: $value, minValue: 0, maxValue: 10, trackHeight: 4,
knobSize: 10, knobColor: .white, fillColor: .red, backgroundColor: .black) { newValue in
    print(newValue)
}
let hview = NSHostingView(rootView: slider2)
hview.frame = CGRect(x: 20, y: 100, width: 200, height: 30)
view.addSubview(hview)
slider.frame = CGRect(x: 20, y: 150, width: 200, height: 30)
slider.cell = CocoaSliderCell(minValue: -10, maxValue: 10, trackHeight: 2, knobSize: 12, style:
.doubleSide, fillColor: .red, backgroundColor: .black)
view.addSubview(slider)

SwiftUI

struct SwiftUIView: View {
		@State var value: CGFloat = 0

    var body: some View {
        CocoaSlider(value: $value)

        CocoaSlider(value: $value, minValue: 0, maxValue: 10, knobColor: .red) { value in
            print(value)
        }

        CocoaSlider(value: $value, onChange: { value in
            print(value)
        })
    }
}

slider

cocoaslider's People

Contributors

nenhall avatar

Stargazers

 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.