分隔线改为 1 物理像素发丝线,修复 UIScreen.main 弃用警告
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import UIKit
|
||||
|
||||
final class HairlineView: UIView {
|
||||
private var heightConstraint: NSLayoutConstraint?
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
backgroundColor = .separator
|
||||
translatesAutoresizingMaskIntoConstraints = false
|
||||
let constraint = heightAnchor.constraint(equalToConstant: 0.5)
|
||||
constraint.isActive = true
|
||||
heightConstraint = constraint
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
required init?(coder: NSCoder) { fatalError() }
|
||||
|
||||
override func didMoveToWindow() {
|
||||
super.didMoveToWindow()
|
||||
let scale = window?.windowScene?.screen.scale ?? 2
|
||||
heightConstraint?.constant = 1.0 / scale
|
||||
}
|
||||
}
|
||||
@@ -133,10 +133,7 @@ final class QuizResultView: UIView {
|
||||
}, for: .touchUpInside)
|
||||
section.addArrangedSubview(button)
|
||||
|
||||
let divider = UIView()
|
||||
divider.backgroundColor = .separator
|
||||
divider.translatesAutoresizingMaskIntoConstraints = false
|
||||
divider.heightAnchor.constraint(equalToConstant: 1.0 / UIScreen.main.scale).isActive = true
|
||||
let divider = HairlineView()
|
||||
section.addArrangedSubview(divider)
|
||||
}
|
||||
return section
|
||||
|
||||
@@ -106,10 +106,7 @@ final class WordDetailViewController: UIViewController {
|
||||
meaningLabel.font = .preferredFont(forTextStyle: .title2)
|
||||
meaningLabel.numberOfLines = 0
|
||||
|
||||
let divider = UIView()
|
||||
divider.backgroundColor = .separator
|
||||
divider.translatesAutoresizingMaskIntoConstraints = false
|
||||
divider.heightAnchor.constraint(equalToConstant: 1.0 / UIScreen.main.scale).isActive = true
|
||||
let divider = HairlineView()
|
||||
|
||||
let exampleTitle = makeCaption("例句")
|
||||
let exampleLabel = UILabel()
|
||||
|
||||
Reference in New Issue
Block a user