Я хочу, чтобы этот эффект был, но iOS13 Изменить UINavigationBarAppearance () не показывать, но альфа изменилась
iOS 12:
Imgur
Расширение и код:
extension UIImage {
func image(alpha: CGFloat) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(size, false, scale)
draw(at: .zero, blendMode: .normal, alpha: alpha)
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return newImage
}
}
//Code:
let imageBg = getGradientImage(bounds: UIScreen.main.bounds)
self.NavigationTitle.alpha = alpha
if #available(iOS 13.0, *) {
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundImage = imageBg?.image(alpha: alpha)
appearance.backgroundColor = UIColor.clear
appearance.shadowColor = nil
navigationController?.navigationBar.standardAppearance = appearance
navigationController?.navigationBar.scrollEdgeAppearance = appearance
navigationController?.navigationBar.compactAppearance = appearance
}else{
self.navigationController?.navigationBar.setBackgroundImage(imageBg?.image(alpha: alpha), for: .default)
self.navigationController?.navigationBar.shadowImage = UIImage()
navigationController?.navigationBar.backgroundColor = .clear
}
self.navigationController?.navigationBar.isTranslucent = true
[1]: https://i.stack.imgur.com/ZhwHv.png