0
0

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 5 years have passed since last update.

カウントアプリ

Posted at

1、StoryboardにLabelと”+”と”ー”のbuttonを配置する
2、下記の処理をViewController.swiftに書く
3、@IBOutletの部分をLabelと紐づける
4、@IBActionの部分をButtonと紐づける


import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var countLabel: UILabel!    
    var count =  0    
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

    @IBAction func countupBotton(_ sender: AnyObject) {
        if count == 10{
            return
        } 
        count = count + 1
        countLabel.text = String(count)
            }

    @IBAction func countdownButton(_ sender: AnyObject) {
        if count == 0{
            return
        }
        count = count - 1
        countLabel.text = String(count)
        }
}
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?