Skip to content

Commit ac24604

Browse files
committed
♻️ 리뷰사항 반영
git push origin iOS/feat#129
1 parent 310fff5 commit ac24604

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

iOS/Layover/Layover/Scenes/UIComponents/Toast.swift

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ final class Toast {
1616
func showToast(message: String) {
1717
let scenes: Set<UIScene> = UIApplication.shared.connectedScenes
1818
let windowScene: UIWindowScene? = scenes.first as? UIWindowScene
19-
let window: UIWindow? = windowScene?.windows.first
19+
guard let window: UIWindow = windowScene?.windows.first else { return }
2020
let toastLabel: UILabel = UILabel()
21-
guard let windowWidth: CGFloat = windowScene?.screen.bounds.width else { return }
22-
guard let windowHeight: CGFloat = windowScene?.screen.bounds.height else { return }
2321
toastLabel.backgroundColor = .background
2422
toastLabel.textColor = .layoverWhite
2523
toastLabel.textAlignment = .center
@@ -29,15 +27,9 @@ final class Toast {
2927
toastLabel.clipsToBounds = true
3028
toastLabel.numberOfLines = 1
3129
toastLabel.layer.opacity = 0.8
32-
let size: CGSize = toastLabel.intrinsicContentSize
33-
toastLabel.frame = CGRect(
34-
x: (windowWidth - size.width) / 2,
35-
y: (windowHeight - size.height) / 2,
36-
width: size.width,
37-
height: size.height)
38-
39-
window?.addSubview(toastLabel)
40-
30+
toastLabel.frame.size = toastLabel.intrinsicContentSize
31+
window.addSubview(toastLabel)
32+
toastLabel.center = window.center
4133
UIView.animate(withDuration: 2.0, delay: 0.1, options: .curveEaseOut, animations: {
4234
toastLabel.alpha = 0.0
4335
}, completion: { _ in

0 commit comments

Comments
 (0)