//swift var backGroundImage = UIImage(named: "顶部Bar") backGroundImage = backGroundImage?.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: UIImageResizingMode.stretch) nav.navigationBar.setBackgroundImage(backGroundImage, for: .default)
nav.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white]
//OC
UIImage *backGroundImage = [UIImage imageNamed:@"顶部Bar"]; backGroundImage = [backGroundImage resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeStretch]; [self.navigationBar setBackgroundImage:backGroundImage forBarMetrics:UIBarMetricsDefault];