분류 전체보기
-
Alamofire, Combine으로 POST 데이터 불러오기GET & POST 2022. 7. 15. 12:48
#1. ContentView import SwiftUI struct ContentView: View { @ObservedObject var randomUserViewModel = RandomUserViewModel() var body: some View { List(randomUserViewModel.randomUsers){ aRandomUser in RandomUserRowView(aRandomUser) } // List(0...100, id:\.self){ index in // RandomUserRowView() // } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }..
-
Post API 호출예GET & POST 2022. 7. 12. 16:25
import UIKit func makePostRequest(){ guard let url = URL(string: "https://jsonplaceholder.typicode.com/posts") else { return } print("Ready...") var request = URLRequest(url: url) //method, body, headers request.httpMethod = "POST" request.setValue("application/json", forHTTPHeaderField: "Content-Type") let body : [String: AnyHashable] = [ "userId" : 1, "title" : "test", "body" : "body1234" ] re..
-
#21. 메뉴(Menu)SwiftUI 앱만들기 2022. 7. 12. 13:44
import SwiftUI let myPets = ["멍멍이","야옹이", "찍찍이"] struct ContentView: View { @State private var shouldShowAlert : Bool = false @State private var myText : String = "" @State private var selected : Int = 0 var body: some View { NavigationView{ VStack(spacing: 20){ Spacer() Text("\(myPets[selected])") .font(.system(size: 60)) .bold() Text("우측 상단에 땡땡땡을 눌러주세요!") .font(.title2) .fontWeight(.black) Spa..
-
#20. 딥링크(DeepLink)SwiftUI 앱만들기 2022. 7. 12. 12:35
#1. App화일 수정 import SwiftUI @main struct _20_DeepLinkApp: App { @State var selectedTab = TabIdentifier.todos var body: some Scene { WindowGroup { TabView(selection: $selectedTab, content: { ToDosView().tabItem{ VStack{ Image(systemName: "list.bullet") Text("할일 목록") } }.tag(TabIdentifier.todos) ProfileView().tabItem{ Image(systemName: "person.circle.fill") Text("프로필") }.tag(TabIdentifier.profile)..
-
#19. 피커뷰(PickerView)SwiftUI 앱만들기 2022. 7. 11. 18:23
#1. ContentView import SwiftUI struct ContentView: View { @State private var selectionValue = 0 let myColorArray = ["Red","Green","Blue"] func changeColor(index: Int) -> Color { switch index{ case 0: return Color.red case 1: return Color.green case 2: return Color.blue default: return Color.red } } var body: some View { VStack(alignment: .center) { Circle() .foregroundColor(self.changeColor(inde..
-
#18. 토스트, 팝업(Toast, Popup)SwiftUI 앱만들기 2022. 7. 11. 17:22
#1.ContentView import SwiftUI import ExytePopupView struct ContentView: View { @State var shouldShowBottomSolidMessage: Bool = false @State var shouldShowBottomToastMessage: Bool = false @State var shouldShowTopSolidMessage: Bool = false @State var shouldShowTopToastMessage: Bool = false @State var shouldShowPopUpMessage: Bool = false //#1. Bottom Solid Message func createBottomSolidMessage() ->..
-
#17. 텍스트필드(TextField, SecureField)SwiftUI 앱만들기 2022. 7. 11. 12:29
#1. ContentView import SwiftUI struct ContentView: View { @State private var userName : String = "" @State private var password : String = "" var body: some View { VStack(spacing:10) { HStack { TextField("사용자 이름", text: $userName) .textFieldStyle(RoundedBorderTextFieldStyle()) .autocapitalization(.none)// 대문자로 시작안하기 .disableAutocorrection(.none) //입력 자동 수정하기 안하기 Button(action: { self.userName = ..
-
#16. 버튼 스타일(Button Style)SwiftUI 앱만들기 2022. 7. 11. 11:48
#1. ContentView import SwiftUI struct ContentView: View { var body: some View { VStack(spacing:30){ //#1.탭버튼 Button(action:{ print("button clicked") }, label: { Text("탭") .fontWeight(.bold) }).buttonStyle(MyButtonStytle(color: Color.blue, type: .tab)) //#2.롱버튼 Button(action:{ print("button clicked") }, label: { Text("롱클릭") .fontWeight(.bold) }).buttonStyle(MyButtonStytle(color: Color.green, type..
-
#15. 로또앱 만들기(QR Code)SwiftUI 앱만들기 2022. 7. 8. 13:55
#1_1. 설정하기 (info.pilist를 source code로 열기 위해 만든다) #1_2. 카메라 권한 설정 #1_3. 웹뷰 접근 권한 #2_1. CodeScannerView (출처:https://github.com/twostraws/CodeScanner) #2_2. CodeScannerView (출처:https://github.com/twostraws/CodeScanner) #2_3.CodeScannerView (출처:https://github.com/twostraws/CodeScanner) #3_1. QRCodeGuideLineView, QR코드 가이드 라인 설정 import SwiftUI struct QRCodeGuideLineView : View{ var body: some View{ Ge..
-
#14. 커스텀 탭뷰(CustomTabView)SwiftUI 앱만들기 2022. 7. 8. 12:02
#1. MyCustomTabView import SwiftUI enum TabIndex{ case home, cart, profile } struct MyCustomTabView: View { @State var tabIndex : TabIndex @State var largerScale : CGFloat = 1.4 //Icon 크기 변경 //MyView 뷰로 이동 func changeMyView(tabIndex: TabIndex ) -> MyView{ switch tabIndex { case .home: return MyView(title: "Home", bgColor: Color.green) case .cart: return MyView(title: "CART", bgColor: Color.purpl..