0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

UIStepperの値を設定する。最小、最大

Posted at

0.UIstepper

appleのドキュメントをGoogle日本語訳すると。”スロットマシン”のメタファーと書いてありました。

####1. コード

  @IBOutlet weak var Label: UILabel!
    
    @IBAction func UIstepper(_ sender: UIStepper) {
        //attrbutesインスペクタでも指定可能
        //AnyObjectの時は let stepper = sender as! UIStepper でキャスト
        
        //Double型
        sender.minimumValue = 0
        sender.maximumValue = 100
        sender.stepValue = 5
        
        //Bool型
        sender.autorepeat = true
        sender.wraps = true
        sender.isContinuous = true
        let num = Int(sender.value)
        
        Label.text = String(num)
    }

####2.解説
UIstepperは最大値、最小値、ステップを変更できます。
他にもBool型でautorepeat(長押し)、wraps(maxまで進むと0に戻る)、Continuous(継続的なイベント)などもあり変更できます

UIstepperの値はsender.Valueで取得できました。

####3.関連記事
Qlita
[Qlita]
[Qlita]
####4.最後に
スロットマシンってなんやろ。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?