[Swift] 웹앱 패키징하기
Swift를 사용하여 웹앱을 패키징하는 방법을 간략하게 소개합니다.
///////////////// AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool{
// Override point for customization after application launch.
UIApplication.shared.statusBarStyle = .lightContent
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
window?.rootViewController = ViewController()
return true
}
///////////////// ViewController.swift
var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
let statusBar: UIView = UIApplication.shared.value(forKey: "statusBar") as! UIView
if statusBar.responds(to: #selector(setter: UIView.backgroundColor)) {
statusBar.backgroundColor = hexStringToUIColor(hex: "#37474f")
}
let menuHeight: CGFloat = 0
self.webView = WKWebView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height - menuHeight))
self.view.addSubview(self.webView)
let request = URLRequest(url: URL(string: "http://www.kimheejae.com")!)
self.webView.load(request)
}
이것도 읽어보세요