Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Toast 기능 구현 #130

Merged
merged 4 commits into from
Nov 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
♻️ 리뷰사항 반영
git push origin iOS/feat#129
  • Loading branch information
chopmozzi committed Nov 30, 2023
commit ac2460403d0c123cea90b3551708e919efe68af7
16 changes: 4 additions & 12 deletions iOS/Layover/Layover/Scenes/UIComponents/Toast.swift
Original file line number Diff line number Diff line change
@@ -16,10 +16,8 @@ final class Toast {
func showToast(message: String) {
let scenes: Set<UIScene> = UIApplication.shared.connectedScenes
let windowScene: UIWindowScene? = scenes.first as? UIWindowScene
let window: UIWindow? = windowScene?.windows.first
guard let window: UIWindow = windowScene?.windows.first else { return }
let toastLabel: UILabel = UILabel()
guard let windowWidth: CGFloat = windowScene?.screen.bounds.width else { return }
guard let windowHeight: CGFloat = windowScene?.screen.bounds.height else { return }
toastLabel.backgroundColor = .background
toastLabel.textColor = .layoverWhite
toastLabel.textAlignment = .center
@@ -29,15 +27,9 @@ final class Toast {
toastLabel.clipsToBounds = true
toastLabel.numberOfLines = 1
toastLabel.layer.opacity = 0.8
let size: CGSize = toastLabel.intrinsicContentSize
toastLabel.frame = CGRect(
x: (windowWidth - size.width) / 2,
y: (windowHeight - size.height) / 2,
width: size.width,
height: size.height)

window?.addSubview(toastLabel)

toastLabel.frame.size = toastLabel.intrinsicContentSize
window.addSubview(toastLabel)
toastLabel.center = window.center
UIView.animate(withDuration: 2.0, delay: 0.1, options: .curveEaseOut, animations: {
toastLabel.alpha = 0.0
}, completion: { _ in