Merge branch 'nt/little-fixes15' into release/3.0.0
This commit is contained in:
commit
a022199e7a
@ -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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user