전체 글


WKScriptMessageHandler(Protocol) 웹페이지에서 실행되는 JavaScript 코드로부터 메시지를 수신하기 위한 인터페이스 웹 뷰 안에서 JavaScript message를 앱에서 응답하는 방법 특히 MessageHandler를 타겟으로 메시지를 전송하면 WebKit에서는 userContentController(_:didReceive:) 함수를 호출 JavaScript에서 MessageHandler를 호출하려면 아래 함수를 호출 window.webkit.messageHandlers..postMessage() WKMessageHandler에서 의 값을 지정 userContentController(_:didReceive:) 웹페이지가 script message를 전송했을 때 func u..


WKUIDelegate(Protocol) : 웹페이지를 대신하여 기본 UI 요소를 표시하는 방법 새 창이 열리는 것을 제어 사용자가 요소를 클릭했을 때 표시되는 기본 메뉴 Item의 동작을 강화 기타 UI 관련 작업 수행 JavaScript 또는 기타 플러그인 콘텐츠를 처리하는 결과로 호출 WKUIDelegate | Apple Developer Documentation The methods for presenting native user interface elements on behalf of a webpage. developer.apple.com webView(_:createWebViewWith:for:windowFeatures:) 새로운 웹뷰를 생성 webView(_:createWebViewWith:..


WKNavigationDelgate 웹뷰의 탐색(navigation) 변경사항을 수락 또는 거부하고 탐색 요청 진행 상황을 추적하는 방법 WKNavigationDelegate | Apple Developer Documentation Methods for accepting or rejecting navigation changes, and for tracking the progress of navigation requests. developer.apple.com webView(_:decidePolicyFor:preferences:decisionHandler:) 웹 페이지의 탐색 허용 여부를 결정할 때 webView(_:decidePolicyFor:preferences:decisionHandler:) | Ap..


UICollectionViewCompositionalLayout(Class) 적응력이 뛰어나고 유연한 시각적 배열로 item을 결합할 수 있는 Layout 개체 CompositionalLayout은 레이아웃을 별개의 시각적 Group으로 나누는 하나 이상의 Section으로 구성 각 Section을 표시하려는 데이터의 가장 작은 단위인 Item들의 Group으로 구성 Group은 Item을 가로 행, 세로 열 또는 사용자 정의 배열로 배치할 수 있음 Layout 구성 코드 func createBasicListLayout() -> UICollectionViewLayout { let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0..


Calendar(struct) 달력 단위와 절대 시점간의 관계를 정의하고, 날짜 계산 및 비교 기능 제공 import Foundation // 달력 선택 let buddhistCalendar = Calendar(identifier: .buddhist) let now = Date() // 사용자의 현재 달력 let calendar = Calendar.current // 날짜 요소에 접근하기 let year = calendar.component(.year, from: now) // 년(Int) let month = calendar.component(.month, from: now) // 월(Int) let day = calendar.component(.day, from: now) // 일(Int) let w..


SnapKit으로 UIScrollView 구성 import UIKit import SnapKit class ViewController: UIViewController { private lazy var scrollView: UIScrollView = { let scrollView = UIScrollView() return scrollView }() private let stackView: UIStackView = { let stackView = UIStackView() stackView.axis = .vertical stackView.spacing = 9 return stackView }() override func viewDidLoad() { super.viewDidLoad() view.backgroun..