2017-01-16 88 views
0

我在navigationBar中存在titleview问题。事情是,当我将视图分配给titleView时,它没有显示。我试过使用navigationItem.title = @"eqweqweq";,但没有任何反应。navigationItem.TitleView无法在iOS 10上工作

涉及的这个视图是由代码创建的,我不知道这是否是问题,因为我使用过的其他ViewControllers完美工作。

有没有在iOS 10中的任何错误,我不能使用titleView?有时它有时不起作用。

我在谷歌搜索,但没有帮助我。我希望有人能帮助我T_T。

谢谢

+1

如果您设置了titleView,则不会使用标题。你能不能展示一下你在做什么的代码? –

回答

0

只使用一个。

任一组的navigationItemtitleView象下面这样:

UILabel *lblTitle = [[UILabel alloc] init]; 
lblTitle.text = @"eqweqweq"; 
lblTitle.backgroundColor = [UIColor clearColor]; 

[lblTitle sizeToFit]; 

self.navigationItem.titleView = lblTitle; 

OR

直接设置的navigationItemtitle象下面这样:

[email protected]"eqweqweq" 
0

请试试这个。这个对我有用。

self.title = "eqweqweq" 

希望这将有助于周到,谢谢

0

最后我已经解决了这个问题!

的问题是这样的功能:

extension UINavigationController{ 
func applyWhiteEffect(){ 
     var bounds = self.navigationBar.bounds 
     let whiteView = UIView() 
     bounds.origin.y = -20 
     bounds.size.height = bounds.size.height + 20 
     whiteView.frame = bounds 
     whiteView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight] 
     whiteView.userInteractionEnabled = false 
     whiteView.backgroundColor = UIColor.whiteColor() 
     whiteView.tag = 1000 
     self.navigationBar.addSubview(whiteView) 
     self.navigationBar.backgroundColor = UIColor.clearColor() 
     self.navigationBar.sendSubviewToBack(whiteView) 
    } 
} 

此函数施加的白色视图和有与和iOS 10中的问题,所以我已经改变到这样的:

func applyWhiteEffect(){ 
     var bounds = self.navigationBar.bounds 
     let whiteView = UIView() 
     bounds.origin.y = -20 
     bounds.size.height = 20 
     whiteView.frame = bounds 
     whiteView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight] 
     whiteView.userInteractionEnabled = false 
     whiteView.backgroundColor = UIColor.whiteColor() 
     whiteView.tag = 1000 
     self.navigationBar.addSubview(whiteView) 
     self.navigationBar.backgroundColor = UIColor.whiteColor() 
     self.navigationBar.sendSubviewToBack(whiteView) 
    } 

更改视图只覆盖状态栏和self.navigationBar.backgroundColor = UIColor.whiteColor()

谢谢你们帮我:D

相关问题