Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /home/hide-tono/tono-n-chi.com/public_html/blog/wp-content/themes/simplicity2/functions.php on line 376
Swiftのお勉強にUICatalogをまねぶ5(UIAlertController-3)

Swiftのお勉強にUICatalogをまねぶ5(UIAlertController-3)

スポンサーリンク

前回はAlert Controllerを途中までやりました。

今回はActionSheet型のAlertを実装していきます。

ActionSheet型Alert

もはや同じ部分ばっかりになってきたんでとりあえずコードから。

ui5-01

2種類ありますが似たようなものです。
UIAlertControllerのpreferredSytleを.ActionSheetにすることでActionSheet型のAlertになります。

[c]
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .ActionSheet)

[/c]

上のやつはこんな感じで表示されます。

ui5-02

下の方は削除ボタンなどで使う赤いスタイルを適用したものです。
UIAlertActionのstyleを.Destructiveにすると赤くなります。

[c]
let destructiveAction = UIAlertAction(title: destructiveButtonTitle, style: .Destructive) { action in
NSLog("The \"Other\" alert action sheet’s destructive action occured.")
}
[/c]

表示は以下のようになります。

ui5-03

以上でUIAlertControllerのサンプル解説はおしまいです。

なんか長かったー。

スポンサーリンク







シェアする

  • このエントリーをはてなブックマークに追加

フォローする

スポンサーリンク