소개
🏫 상시 학생 할인중
강의 금액이 부담되는 학생분들을 위해서 본인 학교 메일 계정으로 예) @***.ac.kr , @***.edu
이메일 보내주시면 전 강의 할인 쿠폰을 보내 드립니다.
👉 jacobko@kakao.com
안녕하세요. 😀
뉴질랜드에서 iOS 개발을 하고 있는 Jacob 입니다.
SwiftUI 을 통해 누구나 쉽게 iOS APP 을 만들수 있도록 다양한 강의를 제작중에 있습니다.
SwiftUI 뿐만 아니라 다양한 iOS 개발 관련 자료들을 저의 Jacob's DevLog 에서 만나실 수 있습니다.
Hello. 😀
I'm Jacob,living in New Zealand.
I'm currently working on creating various tutorials to make it easy for anyone to develop iOS apps through SwiftUI.
You can find not only SwiftUI but also various iOS development-related materials on my Jacob's DevLog.
강의
전체2수강평
게시글
질문&답변
2024.05.28
페이지 이동에 관해 질문이 있습니다 !
안녕하세요 oilater 님. 확인이 늦어 이제 답변드리네요 죄송합니다. 페이지 연결 느낌이 아니라 다른 페이지로 넘기는것은 .fullScreenCover 와 .presentationDetents 을 활용해서 sheet 의 크기와 페이지 전환을 NavigationLink 를 사용하지 않고도 구현 할 수 있습니다. 자세한 사항은 링크를 참조해주세요 https://sarunw.com/posts/swiftui-bottom-sheet/ 감사합니다 예제 코드는 다음과 같습니다. import SwiftUI struct test1: View { @State private var showFullScreen = false var body: some View { VStack { Text("Home Page") .font(.largeTitle) .padding() Button(action: { showFullScreen.toggle() }) { Text("Go to Next Page") .padding() .background(Color.blue) .foregroundColor(.white) .cornerRadius(8) } // .fullScreenCover(isPresented: $showFullScreen) { // NextPageView() // FullScreenColor 와 같이 Sheet} .sheet(isPresented: $showFullScreen, content: { NextPageView() // .presentationDetents([.medium]) // 중간 사이즈 sheet // .presentationDetents([.fraction(0.7)]) // 스크린 사이즈의 70% 만 .presentationDetents([.fraction(0.3)]) // 스크린 사이즈의 30% 만 }) } } } struct NextPageView: View { @Environment(\.presentationMode) var presentationMode var body: some View { VStack { Text("Next Page") .font(.largeTitle) .padding() Button(action: { presentationMode.wrappedValue.dismiss() }) { Text("Go Back") .padding() .background(Color.red) .foregroundColor(.white) .cornerRadius(8) } } .frame(maxWidth: .infinity, maxHeight: .infinity) .background(Color.green) .edgesIgnoringSafeArea(.all) } } #Preview { test1() } (사진)
- 0
- 2
- 55
질문&답변
2024.05.28
Spacer() 를 넣으니 예제처럼 SafeArea 확보가 안됩니다.
안녕하세요 랑프님. 확인이 늦어 이제 답변 드리네요 죄송합니다. iOS15 버전 이후로는 .background 적용시 자동으로 ignoreSafeArea 가 적용되게 xcode 에서 설정이 되었습니다. 그래서 .ignoreSafeArea(edges:[]) 를 사용하시면 위아래 색이 적용안하게 하실 수 있습니다. 보다 자세한 사항은 아래 링크를 확인해 주세요 감사합니다. https://developer.apple.com/documentation/swiftui/view/background(_:ignoressafeareaedges:) (사진) struct MatchedGeomatryEffectInter: View { @State private var isToggled: Bool = false @Namespace private var namespace var body: some View { VStack { if !isToggled { RoundedRectangle(cornerRadius: 20) .matchedGeometryEffect(id: "rectangle", in: namespace) .frame(width: 100, height: 100) // matchedGeometry Effect id 값과 nameSpace } // .offset(y: isToggled ? UIScreen.main.bounds.height * 0.7 : 0) Spacer() if isToggled { RoundedRectangle(cornerRadius: 20) .matchedGeometryEffect(id: "rectangle", in: namespace) .frame(width: 300, height: 100) } } //: VSTACK .frame(maxWidth: .infinity, maxHeight: .infinity) // 질문 답변 // .background(Color.green.ignoresSafeArea(edges: .bottom)) // 위에만 색적용 안되게 하기 .background(Color.green.ignoresSafeArea(edges: [])) // 모든 부위 .top, .bottom, .leading, .traling 적용안시키기 .onTapGesture { withAnimation(.spring()) { isToggled.toggle() } } } }
- 0
- 3
- 67
질문&답변
2024.05.22
Local Notification 예제 문의
안녕하세요 랑프님. 앱이 활성화될 때마다 UIApplication.shared.applicationIconBadgeNumber = 0 으로 뱃지가 초기화되므로, 로컬 알림을 여러 번 발송해도 모든 알림이 뱃지 값이 1인 상태로 도착합니다. 이는 알림의 뱃지 값이 항상 초기화되기 때문에 발생합니다. 이를 해결하기 위해서 UserDefaults 를 사용해서 뱃지 값을 저장하고 불러오는 방법을 사용하면 됩니다. 수정된 코드는 다음과 같습니다. *수정한 부분만 사진으로 올려드리고 전체 코드는 맨아래 있습니다. 앱이 종료 되어도 뱃지값 저장하기 (사진) CancelNotifiactaion 에서 값 초기화 (사진) View에서 화면이 나타날때 reset 하는거 삭제 (사진) 수정된 코드 class NotificationManager { static let instance = NotificationManager() // 인스턴스 생성 func requestAuthorization() { let option: UNAuthorizationOptions = [.alert, .sound, .badge] // UserNotification 접근 UNUserNotificationCenter.current().requestAuthorization(options: option) { (success, error) in if let error = error { print("에러: \(error)") } else { print("성공") } } } func scheduleNotification() { // UserDefaults 에다가 자장할 currentBadgeCount let currentBadgeCount = UserDefaults.standard.integer(forKey: "badgeCount") // 값을 1씩 증가 시킴 let newBadgeCount = currentBadgeCount + 1 // 증가한다음에서는 값을 저장 UserDefaults.standard.set(newBadgeCount, forKey: "badgeCount") // notification 내용 설정 let content = UNMutableNotificationContent() content.title = "Local Notification 테스트 1" content.subtitle = "앱 알람 테스트 중입니다" content.sound = .default content.badge = NSNumber(value: newBadgeCount) // 1씩 증가 시킴 // Trigger 2가지 종류 // 1.시간 기준 : Interval - 몇 초 뒤에 울릴것인지 딜레이 설정 repeats 반복 여부 설정 (최소 1분이여지 반복이 돔) let timeTrigger = UNTimeIntervalNotificationTrigger(timeInterval: 5.0, repeats: false) // 2.날짜 기준 : DateMating 은 DateComponent 기준맞는 알림 var dateComponents = DateComponents() dateComponents.hour = 8 // hour 를 24시간 기준 dateComponents.minute = 30 dateComponents.weekday = 1 // 1은 일요일이 되고, 6은 금요일이 됨 // let calendarTigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: true) // 설정한 값을 NotificationCenter 에 요청하기 let request = UNNotificationRequest( identifier: UUID().uuidString, // 각각의 request ID 값 String 을 uuid 값으로 설정 content: content, trigger: timeTrigger) UNUserNotificationCenter.current().add(request) } // 생성된 Notification Cancel 하기 func cancelNotification() { // peding notification 은 tigger 상에서 만족된 조건이 되어도 더이상 notification 되지 않게 하기 UNUserNotificationCenter.current().removeAllPendingNotificationRequests() // 아이폰 상태바를 내렸을때 남아있는 notification 없애기 UNUserNotificationCenter.current().removeAllDeliveredNotifications() // Cancel 하면 UserDefault 값 초기화 하기 UserDefaults.standard.set(0, forKey: "badgeCount") UIApplication.shared.applicationIconBadgeNumber = 0 } } struct LocalNotificationInter: View { @Environment(\.scenePhase) var scenePhase var body: some View { VStack (spacing: 40) { Button { NotificationManager.instance.requestAuthorization() } label: { Text("권한 요청하기") .font(.title2) .fontWeight(.semibold) .foregroundColor(.black) .padding() .background(Color.green) .cornerRadius(10) } Button { NotificationManager.instance.scheduleNotification() } label: { Text("Time Notification") .font(.title2) .fontWeight(.semibold) .foregroundColor(.black) .padding() .background(Color.green) .cornerRadius(10) } Button { NotificationManager.instance.scheduleNotification() } label: { Text("Calendar Notification") .font(.title2) .fontWeight(.semibold) .foregroundColor(.black) .padding() .background(Color.green) .cornerRadius(10) } Button { NotificationManager.instance.cancelNotification() } label: { Text("Notification 취소하기") .font(.title2) .fontWeight(.semibold) .foregroundColor(.black) .padding() .background(Color.green) .cornerRadius(10) } } //: VSTACK // schne 이 나타 날때 Badge 0 으로 초기화 하기 .onChange(of: scenePhase) { newValue in if newValue == .active { // 0으로 초기화 되지 않게 reset 하지 않기 // UIApplication.shared.applicationIconBadgeNumber = 0 } } } }
- 0
- 2
- 46
질문&답변
2024.05.22
Local Notification 강의 편집오류 있어요
안녕하세요 랑프님. 컷편집 오류 확인하였습니다. 원본파일에서 다시 수정하여 재 업로드 하겠습니다. 감사합니다
- 0
- 2
- 50
질문&답변
2024.05.22
강의중 코드폴딩 단축키 (커맨트+옵션+왼쪽방향키)
안녕하세요 랑프 님. 강의의 내용에 대해 혼동을 드려서 죄송합니다. 단축키 부분 수정하여서 재업로드 하겠습니다. 감사합니다.
- 0
- 2
- 65