diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m index d7f9c5e38..9b31d413f 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m @@ -89,13 +89,10 @@ const CGFloat kMaxTextViewHeight = 98; if (UIAccessibilityIsReduceTransparencyEnabled()) { self.backgroundColor = [UIColor ows_toolbarBackgroundColor]; } else { - UIBlurEffect *blurEffect; - // More muted blur effects look gray when overlayed on white. - blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; - - // We can make our blur effect more muted by increasing this background alpha. - self.backgroundColor = [[UIColor ows_toolbarBackgroundColor] colorWithAlphaComponent:0.4f]; + CGFloat alpha = OWSNavigationBar.backgroundBlurMutingFactor; + self.backgroundColor = [[UIColor ows_toolbarBackgroundColor] colorWithAlphaComponent:alpha]; + UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; [self addSubview:blurEffectView]; [blurEffectView autoPinEdgesToSuperviewEdges]; diff --git a/SignalMessaging/Views/OWSNavigationBar.swift b/SignalMessaging/Views/OWSNavigationBar.swift index 66b89a531..24fe46f1d 100644 --- a/SignalMessaging/Views/OWSNavigationBar.swift +++ b/SignalMessaging/Views/OWSNavigationBar.swift @@ -38,9 +38,33 @@ public class OWSNavigationBar: UINavigationBar { fatalError("init(coder:) has not been implemented") } + @objc + public static let backgroundBlurMutingFactor: CGFloat = 0.5 + override init(frame: CGRect) { super.init(frame: frame) + if !UIAccessibilityIsReduceTransparencyEnabled() { + // Make navbar more translucent than default. Navbars remove alpha from any assigned backgroundColor, so + // to achieve transparency, we have to assign a transparent image. + let color = UIColor.ows_navbarBackground.withAlphaComponent(OWSNavigationBar.backgroundBlurMutingFactor) + let backgroundImage = UIImage(color: color) + self.setBackgroundImage(backgroundImage, for: .default) + let blurEffect = UIBlurEffect(style: .light) + let blurEffectView = UIVisualEffectView(effect: blurEffect) + blurEffectView.isUserInteractionEnabled = false + + // remove hairline below bar. + self.shadowImage = UIImage() + + self.insertSubview(blurEffectView, at: 0) + // On iOS11, despite inserting the blur at 0, other views are later inserted into the navbar behind the blur, + // so we have to set a zindex to avoid obscuring navbar title/buttons. + blurEffectView.layer.zPosition = -1 + + blurEffectView.autoPinEdgesToSuperviewEdges(with: UIEdgeInsets(top: -100, left: 0, bottom: 0, right: 0)) + } + NotificationCenter.default.addObserver(self, selector: #selector(callDidChange), name: .OWSWindowManagerCallDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(didChangeStatusBarFrame), name: .UIApplicationDidChangeStatusBarFrame, object: nil) }