Avoid division by 0
This commit is contained in:
parent
cc4df41fbb
commit
dccfb4e831
|
@ -0,0 +1,18 @@
|
||||||
|
//
|
||||||
|
// UIScreen.swift
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Jed Fox on 2022-12-15.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
extension UIScreen {
|
||||||
|
public var pixelSize: CGFloat {
|
||||||
|
if scale > 0 {
|
||||||
|
return 1 / scale
|
||||||
|
}
|
||||||
|
// should never happen but just in case
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
}
|
|
@ -184,8 +184,8 @@ public final class StatusCardControl: UIControl {
|
||||||
super.didMoveToWindow()
|
super.didMoveToWindow()
|
||||||
|
|
||||||
if let window = window {
|
if let window = window {
|
||||||
layer.borderWidth = 1 / window.screen.scale
|
layer.borderWidth = window.screen.pixelSize
|
||||||
dividerConstraint?.constant = 1 / window.screen.scale
|
dividerConstraint?.constant = 1 / window.screen.pixelSize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ public final class StatusCardControl: UIControl {
|
||||||
NSLayoutConstraint.deactivate(layoutConstraints)
|
NSLayoutConstraint.deactivate(layoutConstraints)
|
||||||
dividerConstraint?.deactivate()
|
dividerConstraint?.deactivate()
|
||||||
|
|
||||||
let pixelSize = 1 / (window?.screen.scale ?? 1)
|
let pixelSize = 1 / (window?.screen.pixelSize ?? 1)
|
||||||
switch layout {
|
switch layout {
|
||||||
case .large(let aspectRatio):
|
case .large(let aspectRatio):
|
||||||
containerStackView.alignment = .fill
|
containerStackView.alignment = .fill
|
||||||
|
|
Loading…
Reference in New Issue