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

【swift】セグメントでの分岐の仕方

Last updated at Posted at 2020-05-29

セグメントの基本設定

UISegmentedControlの基本設定はstorybord上でできます。
スクリーンショット 2020-05-29 22.32.53.png
セグメントの数や、それぞれに入れる文言はここで設定します。

セグメントによって処理を分岐する

選ばれたセグメントの場所(番号)でスイッチするのが良いでしょう。

@IBOutlet weak var segmentedControl: UISegmentedControl!

// セグメントコントロールが何番目に止まっているかでスイッチ
switch segmentedControl.selectedSegmentIndex {
  case 0:
    break

  case 1:
    break

  case 2:
    break

  case 3:
    break

  default:
    break
}
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?