iOS7中都Bar的透明问题

时间:2022-05-22 07:35:29
/*
New behavior on iOS 7.
Default is YES.
You may force an opaque background by setting the property to NO.
If the navigation bar has a custom background image, the default is inferred
from the alpha values of the image—YES if it has any pixel with alpha < 1.0
If you send setTranslucent:YES to a bar with an opaque custom background image
it will apply a system opacity less than 1.0 to the image.
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.
*/
@property(nonatomic,assign,getter=isTranslucent) BOOL translucent NS_AVAILABLE_IOS(3_0); // Default is NO on iOS 6 and earlier. Always YES if barStyle is set to UIBarStyleBlackTranslucent

总的来说,就是ios7中的bar的透明效果是由translucent属性控制的,在ios7中,默认是透明的,可以改为不透明。ios6中好像是通过barStyle来更改bar的透明问题的,不知道用不透明的style和 translucent = Yes 会怎么样?ios7中这个barStyle还有什么用吗?待实验!