Some appearance tweaks

This commit is contained in:
James Magahern
2021-06-14 16:32:51 -07:00
parent ecee3bd9bb
commit d959342180
5 changed files with 46 additions and 18 deletions

View File

@@ -11,12 +11,12 @@ class ReliefButton: UIButton
{
public var constrainedToSquare = true
internal var cornerRadius = CGFloat(8.0) { didSet { setNeedsLayout() } }
internal let shadowView = UIView(frame: .zero)
internal let backgroundView = GradientView(direction: .vertical, colors: ReliefButton.gradientColors(inverted: false, darkMode: false))
static let padding = CGFloat(24.0)
static let cornerRadius = CGFloat(6.0)
static let borderWidth = CGFloat(1.0)
static let borderWidth = CGFloat(1.0 / UIScreen.main.scale)
override var isHighlighted: Bool {
get {
@@ -53,14 +53,12 @@ class ReliefButton: UIButton
shadowView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
shadowView.layer.shadowRadius = 1.0
shadowView.layer.shadowOpacity = 1.0
shadowView.layer.cornerRadius = Self.cornerRadius
shadowView.layer.masksToBounds = false
shadowView.layer.shouldRasterize = true
shadowView.layer.rasterizationScale = UIScreen.main.scale
shadowView.layer.cornerCurve = .continuous
addSubview(shadowView)
backgroundView.layer.cornerRadius = Self.cornerRadius
backgroundView.isUserInteractionEnabled = false
backgroundView.layer.masksToBounds = true
backgroundView.layer.borderWidth = Self.borderWidth
@@ -85,7 +83,7 @@ class ReliefButton: UIButton
if darkMode {
if !inverted {
return [
UIColor(white: 0.30, alpha: 1.0),
UIColor(white: 0.20, alpha: 1.0),
UIColor(white: 0.10, alpha: 1.0)
]
} else {
@@ -159,7 +157,10 @@ class ReliefButton: UIButton
shadowView.frame = backgroundView.frame
let shadowPath = UIBezierPath(roundedRect: shadowView.bounds, cornerRadius: Self.cornerRadius)
let shadowPath = UIBezierPath(roundedRect: shadowView.bounds, cornerRadius: cornerRadius)
shadowView.layer.shadowPath = shadowPath.cgPath
backgroundView.layer.cornerRadius = cornerRadius
shadowView.layer.cornerRadius = cornerRadius
}
}