iOS导航颜色与视图颜色不匹配

时间:2014-10-16 03:56:59

标签: ios iphone

enter image description here

// set the navigation style
self.navigationController?.navigationBar.barTintColor = UIColor(red: 29.0/255.0, green: 202.0/255.0, blue: 255.0/255.0, alpha: 1)
self.navigationController?.navigationBar.barStyle = UIBarStyle.Black

// set the cancel button color to white
cancel.tintColor = UIColor.whiteColor()

// tweet and chars left (140) to white 
tweet.tintColor = UIColor.whiteColor()
charsLeftLabel.textColor = UIColor.whiteColor()

// set the color of the view containing the above two buttons to the same color as the navigation
view.backgroundColor = UIColor(red: 29.0/255.0, green: 202.0/255.0, blue: 255.0/255.0, alpha: 1)

导航中的视图和导航本身有两种不同的色调,尽管我使用相同的UI颜色阴影

为什么会这样?

2 个答案:

答案 0 :(得分:4)

尝试使用以下代码

[self.view setBackgroundColor:[UIColor clearColor]];

而不是

view.backgroundColor = UIColor(red: 29.0/255.0, green: 202.0/255.0, blue: 255.0/255.0, alpha: 1)

即使视图背景中的RGB值为40,197,251,导航栏也有69,209,255

答案 1 :(得分:3)

尝试使用此代码设置导航栏并查看背景颜色。 :

self.navigationController?.navigationBar.barStyle = UIBarStyle.Black
self.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
self.navigationController?.navigationBar.barTintColor = UIColor(red: 29.0/255.0, green: 202.0/255.0, blue: 255.0/255.0, alpha: 1)
self.navigationController?.navigationBar.translucent = false
self.view.backgroundColor = UIColor(red: 29.0/255.0, green: 202.0/255.0, blue: 255.0/255.0, alpha: 1)