我拿了一张普通UITabBar
的并将它的背景图像更改为具有较低高度的自定义背景图像,因此我更改height
了frame
. 起初我得到的是标签栏下方的空白区域。所以我也改变origin
了frame
。但是现在空白区域已经向上移动到标签栏上方,结果如下:
这是在 AppDelegate 中声明标签栏的代码:
self.tabContoller = [[UITabBarController alloc] init];
//customizing the tabbar
UIImage * tabBackgroundImage = [UIImage imageNamed:@"tabBarBg.png"];
self.tabContoller.tabBar.backgroundColor = [UIColor colorWithRed:245.f/255.f green:245.f/255.f blue:245.f/255.f alpha:255.f/255.f];
self.tabContoller.tabBar.backgroundImage = tabBackgroundImage;
//setting the tabbar height to the correct height of the image
CGRect tabR = self.tabContoller.tabBar.frame;
CGFloat diff = tabR.size.height - tabBackgroundImage.size.height;
tabR.size.height = tabBackgroundImage.size.height;
tabR.origin.y += diff;
self.tabContoller.tabBar.frame = tabR;
我想问题在于ViewController
s 将自己绘制在一个恒定空间之上,该空间是常规标签栏的高度。有没有办法改变它?