diff --git a/Session/Onboarding/FakeChatView.swift b/Session/Onboarding/FakeChatView.swift index 8fcf6bbfa..c55096971 100644 --- a/Session/Onboarding/FakeChatView.swift +++ b/Session/Onboarding/FakeChatView.swift @@ -46,12 +46,12 @@ final class FakeChatView : UIView { stackView.axis = .vertical stackView.spacing = spacing stackView.alignment = .fill - stackView.set(.width, to: UIScreen.main.bounds.width) let vInset = Values.smallSpacing stackView.layoutMargins = UIEdgeInsets(top: vInset, leading: Values.veryLargeSpacing, bottom: vInset, trailing: Values.veryLargeSpacing) stackView.isLayoutMarginsRelativeArrangement = true scrollView.addSubview(stackView) stackView.pin(to: scrollView) + stackView.set(.width, to: .width, of: scrollView) addSubview(scrollView) scrollView.pin(to: self) let height = chatBubbles.reduce(0) { $0 + $1.systemLayoutSizeFitting(UIView.layoutFittingExpandedSize).height } + CGFloat(chatBubbles.count - 1) * spacing + 2 * vInset diff --git a/Session/Shared/BaseVC.swift b/Session/Shared/BaseVC.swift index f84514f4d..1c0659f39 100644 --- a/Session/Shared/BaseVC.swift +++ b/Session/Shared/BaseVC.swift @@ -28,6 +28,13 @@ class BaseVC : UIViewController { NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive(_:)), name: .OWSApplicationDidBecomeActive, object: nil) } + override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { + if hasGradient { + let frame = CGRect(x: 0, y: 0, width: size.width, height: size.height) + setUpGradientBackground(frame: frame) + } + } + internal func ensureWindowBackground() { let appMode = AppModeManager.shared.currentAppMode switch appMode { @@ -38,11 +45,11 @@ class BaseVC : UIViewController { } } - internal func setUpGradientBackground() { + internal func setUpGradientBackground(frame: CGRect = UIScreen.main.bounds) { hasGradient = true view.backgroundColor = .clear let gradient = Gradients.defaultBackground - view.setGradient(gradient) + view.setGradient(gradient, frame: frame) } internal func setUpNavBarStyle() { diff --git a/SessionUIKit/Style Guide/Gradients.swift b/SessionUIKit/Style Guide/Gradients.swift index 1970ecc42..a08c24bdb 100644 --- a/SessionUIKit/Style Guide/Gradients.swift +++ b/SessionUIKit/Style Guide/Gradients.swift @@ -16,9 +16,9 @@ public final class Gradient : NSObject { @objc public extension UIView { - @objc func setGradient(_ gradient: Gradient) { + @objc func setGradient(_ gradient: Gradient, frame: CGRect = UIScreen.main.bounds) { let layer = CAGradientLayer() - layer.frame = UIScreen.main.bounds + layer.frame = frame layer.colors = [ gradient.start.cgColor, gradient.end.cgColor ] if let existingSublayer = self.layer.sublayers?[0], existingSublayer is CAGradientLayer { self.layer.replaceSublayer(existingSublayer, with: layer)