From 9b0ba8441fb6bffc527b1e6b61f929a5f4e1279f Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Mon, 18 Nov 2019 15:23:44 -0800 Subject: [PATCH] No shadows on avatars --- SignalMessaging/Views/AvatarImageView.swift | 47 +-------------------- 1 file changed, 2 insertions(+), 45 deletions(-) diff --git a/SignalMessaging/Views/AvatarImageView.swift b/SignalMessaging/Views/AvatarImageView.swift index 251845663d..f0bdef48b4 100644 --- a/SignalMessaging/Views/AvatarImageView.swift +++ b/SignalMessaging/Views/AvatarImageView.swift @@ -7,8 +7,6 @@ import UIKit @objc public class AvatarImageView: UIImageView { - private let shadowLayer = CAShapeLayer() - public init() { super.init(frame: .zero) self.configureView() @@ -36,32 +34,12 @@ public class AvatarImageView: UIImageView { self.layer.magnificationFilter = .trilinear self.layer.masksToBounds = true - self.layer.addSublayer(self.shadowLayer) - self.contentMode = .scaleToFill } override public func layoutSubviews() { - self.layer.cornerRadius = self.frame.size.width / 2 - - // Inner shadow. - // This should usually not be visible; it is used to distinguish - // profile pics from the background if they are similar. - self.shadowLayer.frame = self.bounds - self.shadowLayer.masksToBounds = true - let shadowBounds = self.bounds - let shadowPath = UIBezierPath(ovalIn: shadowBounds) - // This can be any value large enough to cast a sufficiently large shadow. - let shadowInset: CGFloat = -3 - shadowPath.append(UIBezierPath(rect: shadowBounds.insetBy(dx: shadowInset, dy: shadowInset))) - // This can be any color since the fill should be clipped. - self.shadowLayer.fillColor = UIColor.black.cgColor - self.shadowLayer.path = shadowPath.cgPath - self.shadowLayer.fillRule = .evenOdd - self.shadowLayer.shadowColor = (Theme.isDarkThemeEnabled ? UIColor.white : UIColor.black).cgColor - self.shadowLayer.shadowRadius = 0.5 - self.shadowLayer.shadowOpacity = 0.15 - self.shadowLayer.shadowOffset = .zero + super.layoutSubviews() + layer.cornerRadius = frame.size.width / 2 } } @@ -197,7 +175,6 @@ public class ConversationAvatarImageView: AvatarImageView { @objc public class AvatarImageButton: UIButton { - private let shadowLayer = CAShapeLayer() // MARK: - Button Overrides @@ -205,25 +182,6 @@ public class AvatarImageButton: UIButton { super.layoutSubviews() layer.cornerRadius = frame.size.width / 2 - - // Inner shadow. - // This should usually not be visible; it is used to distinguish - // profile pics from the background if they are similar. - shadowLayer.frame = bounds - shadowLayer.masksToBounds = true - let shadowBounds = bounds - let shadowPath = UIBezierPath(ovalIn: shadowBounds) - // This can be any value large enough to cast a sufficiently large shadow. - let shadowInset: CGFloat = -3 - shadowPath.append(UIBezierPath(rect: shadowBounds.insetBy(dx: shadowInset, dy: shadowInset))) - // This can be any color since the fill should be clipped. - shadowLayer.fillColor = UIColor.black.cgColor - shadowLayer.path = shadowPath.cgPath - shadowLayer.fillRule = .evenOdd - shadowLayer.shadowColor = (Theme.isDarkThemeEnabled ? UIColor.white : UIColor.black).cgColor - shadowLayer.shadowRadius = 0.5 - shadowLayer.shadowOpacity = 0.15 - shadowLayer.shadowOffset = .zero } override public func setImage(_ image: UIImage?, for state: UIControl.State) { @@ -245,7 +203,6 @@ public class AvatarImageButton: UIButton { layer.minificationFilter = .trilinear layer.magnificationFilter = .trilinear layer.masksToBounds = true - layer.addSublayer(shadowLayer) contentMode = .scaleToFill }