http://www.cocoacontrols.com/platforms/ios/controls/qbkoverlaymenuview https://github.com/hollance/MHTabBarController/
- overlay menu機能はQBKOverlayMenuViewで完結
- QBKRootViewControllerがQBKOverlayMenuViewを保持
- viewDidLoadの以下の2行でviewにoverlay menuが追加され、表示される
_qbkOverlayMenu = [[QBKOverlayMenuView alloc] initWithDelegate:self position:kQBKOverlayMenuViewPositionBottom offset:offset];
[_qbkOverlayMenu setParentView:[self view]];
- selfを渡しているのはmenuのdelegateを自分が処理したいため
- setParentViewの中でaddSubViewしていて、その時点で表示
- その後のaddButtonWithImageでunfold時に表示する画像を追加
[_qbkOverlayMenu addButtonWithImage:[UIImage imageNamed:@"rw-button.png"] index:0];
- このdemoのソースでは4つが固定なのでそこが微妙かも
QBK_OVERLAY_MENU_MAX_ADDITIONAL_BUTTONSで「4」を指定しているけど、addButtonWithImageの前とかに指定したらいいんじゃないのかな
- このdemoのソースでは4つが固定なのでそこが微妙かも
- QBKOverlayMenuViewDelegate Protocolを宣言
- (void)overlayMenuView:(QBKOverlayMenuView *)overlayMenuView didActivateAdditionalButtonWithIndex:(NSInteger)index;
- unfold時にボタンがtapされたら呼ばれてtapしたindexが渡されてくる
- (void)didPerformUnfoldActionInOverlayMenuView:(QBKOverlayMenuView *)overlaymenuView;
- unflodしたら呼び出される
- (void)didPerformFoldActionInOverlayMenuView:(QBKOverlayMenuView *)overlaymenuView;
- flodしたら呼び出される
- (void)overlayMenuView:(QBKOverlayMenuView *)overlayMenuView didActivateAdditionalButtonWithIndex:(NSInteger)index;
-
- (void)setParentView:(UIView *)viewcreateFoldedMainFrameForPositionでガムシャラに[_parentView bounds]でrootViewのサイズなどを見ながら表示位置を計算setClipsToBounds:YESにしてるけどコレは何用だろう?setupMainButtonメソッドで初期値であるfoldのbuttonを作り、setAutoresizingMask:UIViewAutoresizingFlexibleLeftMarginでfold時もunfold時も常に右端にmainButtonが来るように配置、tap時のactionをmainButtonPressedに設定- addSubviewでそのbuttonを追加
_mainBackgroundImageViewにunfold時のbackground imageを作り、addSubviewで追加、sendSubviewToBackでmainButtonより背面へ配置、setAlphaで透明化- 最後に
setupContentViewでfold時のcontentsのviewを作成
-
- (void)setupContentViewcreateFoldedContentViewFrameForPositionでfoldのcontentsを作成setClipsToBounds:YESでfoldのcontents(この場合矢印)を非表示(はみ出ているところを非表示)にする- これYESだと出なくてNOだと出る意味がわからない。どういう状態になっているんだろ
setAutoresizingMask:UIViewAutoresizingFlexibleWidth- これがないと矢印出て来ないけど、初期の位置がどうなっているかわからず