这是怎么做的?中央标签栏按钮的圆顶效果?它是圆顶图像在规则中心形状的标签按钮顶部的简单投影吗?或者还有什么?
问问题
714 次
1 回答
3
您可以通过以下方式实现这一目标,
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];
请检查这些链接:http: //idevrecipes.com/2010/12/16/raised-center-tab-bar-button/
您将在https://github.com/boctor/idev-recipes/tree/master/RaisedCenterTabBar获得完整的源代码
于 2012-08-14T19:49:06.457 回答