์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Tags
- visionOS
- ํจ์คํธ์บ ํผ์ค
- Flutter
- swift
- CollectionView
- rxcocoa
- raywenderlich
- Kuring
- SwiftUI
- ๋ฐฑ์ค
- TCA
- ios
- tableView
- Lv2
- Xcode
- XCTest
- node.js
- Swfit
- BOJ
- ํ๋ก๊ทธ๋๋จธ์ค
- UIKit
- designpattern
- RxSwift
- BFS
- realm
- arkit
- SnapKit
- MVVM
- combine
- reactorkit
Archives
- Today
- Total
lgvv98
[SwiftUI] Alert ๋ณธ๋ฌธ
Alert
โ SwiftUI์์ Alert๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ์์๋ณด์.
์์ฃผ ๊ฐ๋จํ ๋ด์ฉ์ ๊ธฐ๋ฐ์ผ๋ก ์ปค์คํ ํ๋ ๊ฒ์ ์์์ ํด๋ณด๊ธฐ!
import SwiftUI
struct contentView: View {
// struct๋ class์ ๋ค๋ฅด๊ฒ ๋ฐ์ดํฐ๊ฐ ๊ณ ์ ์ด๋ผ์ ๋ณ๊ฒฝ์ ํ๋ ค๋ฉด @stateํค์๋ ์ฌ์ฉ
// mutating๊ณผ ๋ฎ์์๋ค.
@State var shouldShowAlert: Bool = false
var body: some View {
Button(
action: {
print("ํ์ธ ๋ฒํผ์ด ํด๋ฆญ๋์๋ค.")
self.shouldShowAlert = true
}) {
Text("ํ์ธ")
.fontWeight(.bold)
.foregroundColor(.white)
.padding()
.frame(width: 80)
.background(Color.blue)
.cornerRadius(20)
}.alert(isPresented: $shouldShowAlert) { // binding์ด๋ฏ๋ก ๋ฌ๋ฌ์ธ์ธ!
Alert(title: Text("์๋ฆผ์ฐฝ์
๋๋ค!"))
}
}
}
'apple > ๐ SwiftUI & Combine' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[SwiftUI] NavigationView (0) | 2022.05.18 |
---|---|
[SwiftUI] List (tableView in UIKit) (0) | 2022.05.18 |
[SwiftUI] VStack, HStack, ZStack (0) | 2022.05.18 |
[SwiftUI] How to set Image in SwiftUI (0) | 2022.05.18 |
[SwiftUI] Info.plist๊ฐ ์์ ๋๐ค (0) | 2022.02.23 |
Comments