0
我需要将我的标签栏放在屏幕的顶部。UITabBar屏幕顶部
我试过,我做到了,这是代码:
override func viewDidLoad() {
self.tabBar.frame = CGRectMake(0, 90, self.view.bounds.size.width, self.view.bounds.size.height);
self.tabBar.autoresizingMask = UIViewAutoresizing.FlexibleWidth
}
问题是我,当我把我的设备的屏幕。
我应该重新生成这样的布局和变化:
self.tabBar.frame = CGRectMake(0, 80, self.view.bounds.size.width, self.view.bounds.size.height);
我怎么能每次都改变这一点,你打开屏幕?
编辑:
新代码:
override func viewDidLayoutSubviews()
{
//check tabBar not null
if (self.tabBar != nil)
{
//make changes in frame here according to orientation if any
self.tabBar.frame = CGRect(x: 00, y: 20, width:self.view.bounds.size.width, height: 49)
}
}
override func viewDidLoad()
{
//Make changes in frame according to your requirement
self.tabBar.frame = CGRectMake(0, 20, self.view.bounds.size.width,49);
//resizing here
self.tabBar.autoresizingMask = UIViewAutoresizing.FlexibleTopMargin;UIViewAutoresizing.FlexibleLeftMargin;UIViewAutoresizing.FlexibleWidth;UIViewAutoresizing.FlexibleRightMargin;
}
当我尝试写函数返回我这个错误:“UITabBar不是NSString的子类型” – Stephany 2015-02-09 14:54:04
我做了一些改变,即只增加了自我tabBar。它在viewDidLayoutSubviews方法中显示此错误。 – 2015-02-09 15:00:52
我用新的代码编辑了问题,但它给了我同样的错误 – Stephany 2015-02-09 15:05:12