UITabBar
3つのタブバーアイテムで使用しています。センタータブの項目をカスタマイズしたい。隆起したタブバーボタンのように。
UITabBarController
それを追加してカスタマイズする方法を知っています。でもカスタマイズしたいUITabBar
。
次のように、カスタマイズされたボタンを中央のタブ バー アイテムとしてタブ バーに追加したいと考えています。
UITabBar
3つのタブバーアイテムで使用しています。センタータブの項目をカスタマイズしたい。隆起したタブバーボタンのように。
UITabBarController
それを追加してカスタマイズする方法を知っています。でもカスタマイズしたいUITabBar
。
次のように、カスタマイズされたボタンを中央のタブ バー アイテムとしてタブ バーに追加したいと考えています。
これをチェックしてくださいhttp://idevrecipes.com/2010/12/16/raised-center-tab-bar-button/
UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0.0, 0.0, buttonImage.size.width, buttonImage.size.height);
[button setBackgroundImage:buttonImage forState:UIControlStateNormal];
[button setBackgroundImage:highlightImage forState:UIControlStateHighlighted];
CGFloat heightDifference = buttonImage.size.height - self.tabBar.frame.size.height;
if (heightDifference < 0)
button.center = self.tabBar.center;
else
{
CGPoint center = self.tabBar.center;
center.y = center.y - heightDifference/2.0;
button.center = center;
}
[self.view addSubview:button];
あなたは変えられる
backgroundImage property
selectedImageTintColor property
selectionIndicatorImage property
tintColor property
ウタバーの
背景画像で達成できるかもしれません。そうでない場合は、独自のタブバーを作成する必要があります。