的背景图案 - (void)setBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state barMetrics:(UIBarMetrics )barMetrics 注意:UIBarMetrics是一个枚举,如下:(defaulf风格会充满背景) typedef NS_ENUM(NSInteger, UIBarMetrics) { UIBarMetricsDefault UIBarMetricsCompactPrompt, }; 获取背景图案 - (UIImage *)backgroundImageForState:(UIControlState)state barMetrics:(UIBarMetrics forLeftSegmentState:(UIControlState)leftState rightSegmentState:(UIControlState)rightState barMetrics:(UIBarMetrics contentPositionAdjustmentForSegmentType:(UISegmentedControlSegment)leftCenterRightOrAlone barMetrics:(UIBarMetrics
- (void)setBackgroundImage:(nullable UIImage *)backgroundImage forBarMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; - (nullable UIImage *)backgroundImageForBarMetrics:(UIBarMetrics )barMetrics; 上面两个方法用于设置和获取导航栏的背景图案,这里需要注意,默认背景图案是不做缩放处理的,所以我们使用的图片尺寸要和导航栏尺寸匹配,这里面还有一个UIBarMetrics参数,这个参数设置设备的状态 ,如下: typedef NS_ENUM(NSInteger, UIBarMetrics) { UIBarMetricsDefault,//正常竖屏状态 UIBarMetricsCompact )barMetrics; - (CGFloat)titleVerticalPositionAdjustmentForBarMetrics:(UIBarMetrics)barMetrics; 还有一个细节
statusBar的背景色 注意:一旦你设置了navigationBar的- (void)setBackgroundImage:(UIImage *)backgroundImage forBarMetrics:(UIBarMetrics blue: 233/255, alpha: 1.0); //去掉navigationBar下的黑线 appear.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default 可以去掉navigationBar下的黑线,代码如下 //去掉navigationBar下的黑线 appear.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default
blue: 244/255, alpha: 1.0); //去掉navigationBar下的黑线 appear.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default UIColor.whiteColor(); self.navigationController.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default
setBackgroundImage:(nullable UIImage *)backgroundImage forToolbarPosition:(UIBarPosition)topOrBottom barMetrics:(UIBarMetrics barMetrics; - (nullable UIImage *)backgroundImageForToolbarPosition:(UIBarPosition)topOrBottom barMetrics:(UIBarMetrics
setBackgroundImage:(UIImage *)backgroundImage forBarPosition:(UIBarPosition)barPosition barMetrics:(UIBarMetrics )barMetrics ; - (UIImage *)backgroundImageForBarPosition:(UIBarPosition)barPosition barMetrics:(UIBarMetrics
self.navigationGradualChangeBackgroundView == nil) { self.setBackgroundImage(UIImage(), for: UIBarMetrics.default func removeNavigationBackgroundColor() -> Void { self.setBackgroundImage(nil, for: UIBarMetrics.default
appear.backgroundColor = ZJColor.mainColor; //去掉navigationBar下的黑线 appear.setBackgroundImage(UIImage(), for: UIBarMetrics.default
self.navigationGradualChangeBackgroundView == nil) { self.setBackgroundImage(UIImage(), for: UIBarMetrics.default func removeNavigationBackgroundColor() -> Void { self.setBackgroundImage(nil, for: UIBarMetrics.default
blue: 13/255, alpha: 1.0); //去掉navigationBar下的黑线 appear.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default