码迷,mamicode.com
首页 > 编程语言 > 详细

swift之Mac中NSStepper

时间:2019-01-30 17:11:20      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:str   cto   sel   rac   back   private   设置   mac   默认   

//步进器

    fileprivate let stepper : NSStepper = {

        let stepper = NSStepper(frame: NSMakeRect(0, 0, 100, 40))

        stepper.wantsLayer = true

        //设置背景色

        stepper.layer?.backgroundColor = NSColor.cyan.cgColor

        //最小值

        stepper.minValue = 5

        //最大值

        stepper.maxValue = 10

        //步长

        stepper.increment = 0.2

        //循环,YES - 超过最小值,回到最大值;超过最大值,来到最小值。

        stepper.valueWraps = false

        //默认为YES-用户交互时会立即放松ValueChanged事件,NO 则表示只有等用户交互结束时才放松ValueChanged事件

        stepper.isContinuous = false

        ///默认为 YES-按住加号或减号不松手,数字会持续变化.continuous = NO 时才有意义。

        stepper.autorepeat = true

        stepper.action = #selector(stepperAction(sender:))

        return stepper

    }()

    

    @objc func stepperAction(sender: NSStepper) {

        let theValue = sender.intValue

        let theFloatValue = sender.floatValue

        

    }

swift之Mac中NSStepper

标签:str   cto   sel   rac   back   private   设置   mac   默认   

原文地址:https://www.cnblogs.com/sundaymac/p/10338587.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!