自分で実装する場合は、カスタムビューを作成し、ビューコントローラのボタンのボタンクリックイベントを追加することができます。
また、カスタムビューが表示されるかどうかを識別するブール値変数を作成します。メニュービューが表示されていない場合
クリックで、その後、次の操作を行います。あなたはこれまでにしようとしているものを投稿する必要があります
-(void)viewDidLoad
{
...
// ---------------------------------------------
// create the custom menu view off screen
// ---------------------------------------------
menuView = [[MenuView alloc] initWithFrame:CGRectMake(-320, 0, 320, 480)];
menuView.alpha = 0; // hide it so it doesn't show at the start, only show when slide in
[self.view addSubview:menuView];
...
}
-(void)toggleMenu
{
if(menuIsVisible)
{
menuIsVisible = NO;
[self hideMenu];
}
else
{
menuIsVisible = YES;
[self showMenu];
}
}
-(void)hideMenu
{
[UIView animateWithDuration:0.5 animations:^{
// note CGAffineTransforms doesn't use coordinates, they use offset
// so an offset of (0,0) would bring the menuView back to the coordinate
// when it was first instantiated, in our case, (-320, 0).
menuView.transform = CGAffineTransformMakeTranslation(0,0);
} completion:^{
// hide the menu
menuView.alpha = 0;
}];
}
-(void)showMenu
{
// show the menu
menuView.alpha = 1;
[UIView animateWithDuration:0.5 animations:^{
// note CGAffineTransforms doesn't use coordinates, they use offset
// so an offset of (320,0) from coordinate (-320,0) would slide the
// menuView out into view
menuView.transform = CGAffineTransformMakeTranslation(320,0);
}];
}
。 – jtbandes
「それは少しうまくいく」とはどういう意味ですか?それは何をしたのですか?それはあなたが望むものとどのように違うのですか? –
ok "メニュー"が正しく表示されていますが、アルファブレンディング効果がありますが、理解できません。 – Phil