このチュートリアルに従って、iPhone の UITabBar に素敵な矢印ができました。
iPadでも同じことをしたかったのですが、うまくいかないようです。
私は試した
- (CGFloat) horizontalLocationFor:(NSUInteger)tabIndex
{
CGFloat tabItemWidth;
CGFloat halfTabItemWidth;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
tabItemWidth = 320 / tabBarController.tabBar.items.count;
halfTabItemWidth = (tabItemWidth / 2.0) - (tabBarArrow.frame.size.width / 2.0);
}
else
{
tabItemWidth = 768 / tabBarController.tabBar.items.count;
halfTabItemWidth = (tabItemWidth / 2) - (tabBarArrow.frame.size.width / 2);
}
return (tabIndex * tabItemWidth) + halfTabItemWidth;
}
例に従って、iPad の tabBar の寸法を取りますが、矢印はまだ各タブの中央にはありません。
何か助けはありますか?