- 概要:PKRevealControllerはエレガントなiOSビューコントローラコンテナです。
複数のコントローラのビュー階層構造を簡単に設定できる柔軟性が高いのビューコントローラコンテナです。
- ダウンロードURL:https://github.com/pkluz/PKRevealController
- 開発者:Philip Kluz
- ブログ:https://github.com/pkluz
- サポート: Xcode4.5+、iOS5.0+、ARC
- ライセンス:MIT
- メイン機能:
①豊富なビューコントローラコンテナ機能
②エレガントなブロックAPI
③左右両方からのサイドビューのプレゼンテーションをサポート
④iPhoneとiPad両方サポート
⑤デバイスの縦向き/横向きを両方サポート - 導入方法:
- cocoapodsを利用、導入するのは一番簡単です。Podfileに「pod ‘PKRevealController’」を追加、下記コマンドを実行するだけで、完了です。
$ pod install
cocoapodsに関して、本サイト以前の文章「開発レシピ:Objective-Cのライブラリ管理ツール CocoaPods」を参照してください。
次は手動で導入する方法を紹介します。 - ダウンロードURLから直接にダウンロードする。
gitを利用してソースを取得する場合、ターミナルで以下のコマンドを実行する。
$ git clone https://github.com/pkluz/PKRevealController.git
- PKRevealControllerをプロジェクトに追加する
「PKRevealController\Controller」フォルダをプロジェクトにドラッグ&ドロップする。
※ポップアップダイアログの「Copy items into destination group’s folder(if needed)」とターゲットチェックボクスの選択を忘れないでください。 - QuartzCore.frameworkをプロジェクトに追加する
ターゲットの「Build Phases」⇒「Link Binary With Libraries」セクション左下の「+」ボタンを押下ライブラリの選択画面で「QuartzCore.framework」を選択、「Add」ボタンを押下。
- 実装方法:
①ヘッダーファイルをインポートする:
#import "PKRevealController.h"
②PKRevealControllerオブジェクトの作成:
- // PKRevealControllerのオプション設定
- // オプションの詳細:⑤を参照
- NSDictionary *options = @{
- PKRevealControllerAllowsOverdrawKey : [NSNumber numberWithBool:YES],
- PKRevealControllerDisablesFrontViewInteractionKey : [NSNumber numberWithBool:YES]
- };
- // PKRevealControllerオブジェクトの作成
- PKRevealController *revealController = [PKRevealController revealControllerWithFrontViewController:frontVC leftViewController:leftVC options:options];
- self.window.rootViewController = revealController;
③サイトビューの幅設定:
viewDidLoadメソッドの中で設定する
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- [self.revealController setMinimumWidth:220.0f maximumWidth:244.0f forViewController:self];
- }
④サイドビューの間にメッセージ送信
revealControllerを通じてお互いにメッセージ送信できる
⑤PKRevealControllerのオプション一覧
- /*
- * フロントビューの移動アニメーションかかる時間
- *
- * @default 0.185sec
- * @value NSNumber containing an NSTimeInterval (double)
- */
- extern NSString * const PKRevealControllerAnimationDurationKey;/*
- * フロントビューの移動アニメーションカーブ設定
- *
- * @default UIViewAnimationCurveLinear
- * @value NSNumber containing a UIViewAnimationCurve (NSUInteger)
- */
- extern NSString * const PKRevealControllerAnimationCurveKey;/*
- * コントローラのアニメーションタイプ
- *
- * @default PKRevealControllerAnimationTypeStatic
- * @value NSNumber containing a PKRevealControllerAnimationType (NSUInteger)
- */
- extern NSString * const PKRevealControllerAnimationTypeKey;/*
- * オーバードロー可否の設定
- *
- * @default YES
- * @value NSNumber containing BOOL
- */
- extern NSString * const PKRevealControllerAllowsOverdrawKey;
- /*
- * フロントビュー移動をトリガするスワイプ速度の最小値
- *
- * @default 800.0f
- * @value NSNumber containing CGFloat
- */
- extern NSString * const PKRevealControllerQuickSwipeToggleVelocityKey;
- /*
- * サイトビューが表示される時、フロントビューのインタラクションを無効するかどうかの設定
- *
- * @default YES
- * @value NSNumber containing BOOL
- */
- extern NSString * const PKRevealControllerDisablesFrontViewInteractionKey;
- /*
- * フロントビュー全体にUIPanGestureRecognizerを設定、パンジェスチャーを感知するかどうかの設定
- *
- * @default YES
- * @value NSNumber containing BOOL
- */
- extern NSString * const PKRevealControllerRecognizesPanningOnFrontViewKey;
- /*
- * フロントビュー全体にUITapGestureRecognizerを設定、サイドビューが表示される場合、
- * スナップバック・オン・タップ機能を有効するかどうかの設定
- *
- * @default YES
- * @value NSNumber containing BOOL
- */
- extern NSString * const PKRevealControllerRecognizesResetTapOnFrontViewKey;