概要
ステータスバーの上にエラーや完了通知メッセージを表示するAlertBarを作りました。
簡単なものですが、開発初期段階でデザインが決まってないときやモックなどで便利になるかと思います。
https://github.com/jinSasaki/AlertBar
気に入ったらStarお願いします。
環境
- Swift 2.0
- iOS 8.0
- ARC
CocoaPodsでインストール
(CocoaPodsのインストール方法は省略)
Podfile
に以下を追加
pod "AlertBar"
使い方
はじめに
AlertBar
をimport
import UIKit
import AlertBar
class ViewController: UIViewController {
...
メッセージを表示
AlertBar
には
- Success
- Error
- Notice
- Warning
- Info
タイプが用意してあります。
それぞれ予め文字色と背景色が設定されています。
メッセージを表示するときは
AlertBar.show(.Success, message: "This is a Success message.")
と書きます。
また、背景色と文字色を個別に設定することもできます。
Custom
タイプを設定し、背景色とと文字色を .Custom(BackgroundColor, TextColor)
のように指定します。
AlertBar.show(.Custom(UIColor.lightGrayColor(), UIColor.blackColor()), message: "This is a Custom message.")
メッセージの表示時間
AlertBar
はメッセージの表示時間も変更することができます。
AlertBar.show(.Success, message: "This is a Success message.", duration: 10)