Open chaneeii opened 2 years ago
Nib 파일을 Preview 한 파일
//#if DEBUG import SwiftUI struct AlarmRepresentable: UIViewRepresentable { typealias UIViewType = AlarmListCell func makeUIView(context: Context) -> AlarmListCell { // let xib = UINib(nibName: "AlramListCell", bundle: nil) // return AlarmListCell() return UINib(nibName: "AlramListCell", bundle: nil) .instantiate(withOwner: nil, options: nil).first as! AlarmListCell } func updateUIView(_ uiView: AlarmListCell, context: Context) {} } struct AlarmPreview: PreviewProvider { static var previews: some View { AlarmRepresentable() .frame(width: 340, height: 123) .previewLayout(.sizeThatFits) } } //#endif
SwiftUI Preview
import SwiftUI struct HomeViewController_Previews: PreviewProvider { static var previews: some View { Container().edgesIgnoringSafeArea(.all) } struct Container: UIViewControllerRepresentable { func makeUIViewController(context: Context) -> UIViewController { let layout = UICollectionViewLayout() let homeViewController = HomeViewController(collectionViewLayout: layout) return UINavigationController(rootViewController: homeViewController) } func updateUIViewController(_ uiViewController: UIViewController, context: Context) {} typealias UIViewControllerType = UIViewController } }
Nib 파일을 Preview 한 파일
SwiftUI Preview