| 导语 为了方便探讨,我把通过setBackgroundImage: forBarPosition: barMetrics:方法设置的image称为backgroundImage
translucent、barTintColor、backgroundImage三者共同决定了UINavigationBar的背景效果,而translucent在中间起非常关键的作用,它决定了系统如何使用barTintColor和backgroundImage去设置UINavigationBar的背景效果。
一、translucent设置为NO
如果translucent设置为NO,注意是“设置为NO”,也就是主动调用setter方法,这和“值为NO”有区别,区别在什么地方后面再讲。主动设置为NO,系统会怎样使用barTintColor和backgroundImage去设置UINavigationBar的背景效果呢?先看一下系统注释:
If you send setTranslucent:NO to a bar with a translucent custom background image
it will provide an opaque background for the image using the bar's barTintColor if defined,
or black for UIBarStyleBlack or white for UIBarStyleDefault if barTintColor is nil.
主要意思是,如果设置为NO,backgroundImage若是半透明的图