自定义UITabBar和ViewController之间的空间 [英] Space between custom UITabBar and ViewController

查看:118
本文介绍了自定义UITabBar和ViewController之间的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拍了一张普通的 UITabBar 并将它的背景图像更改为高度较低的自定义图像,所以我更改了高度框架
起初我得到的是标签栏下方的空白区域。所以我也改变了框架原点。但现在空白区域已经向上移动到标签栏上方,这就是结果:

I took a regular UITabBar and changed it's background image to a custom one which has a lower height, so I changed the height of the frame. At first what I got is a blank space below the tab bar. so I changed the origin of the frame too. But now the blank space has moved up above the tab bar and this is the result:

这是宣布AppDelegate中标签栏的代码:

And this is the code declaring the tab bar in the 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将自己绘制在常量空间上方,该空间是常规标签栏的高度。有没有办法改变它?

I guess that the problem is that the ViewControllers draw themselves above a constant space which is the height of the regular tab bar. Is there any way to change it?

推荐答案

将你的UITabBarController的子视图更改为一个完整大小的框架,这对我有用: / p>

Change your UITabBarController's subviews to a full-sized frame, this worked for me:

[[yourTabBarController.view.subviews objectAtIndex:0] setFrame:CGRectMake(0, 0, 320, 480)];

这篇关于自定义UITabBar和ViewController之间的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆