Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using SwiftUI preview with UIView
//
// TableViewCellPreview.swift
// iOS12App
//
// Created by Kazuma Koze on 2020/03/05.
// Copyright © 2020 Climb App. All rights reserved.
//
import SwiftUI
@available(iOS 13.0, *)
struct TableViewCellPreview: PreviewProvider, UIViewRepresentable {
static var previews: some View {
Group {
TableViewCellPreview()
.environment(\.sizeCategory, .medium)
.previewLayout(.sizeThatFits)
TableViewCellPreview()
.environment(\.sizeCategory, .accessibilityExtraExtraExtraLarge)
.previewLayout(.sizeThatFits)
}
}
func makeUIView(context: UIViewRepresentableContext<TableViewCellPreview>) -> TableViewCell {
let nib = UINib(nibName: String(describing: TableViewCell.self), bundle: nil)
let cell = nib.instantiate(withOwner: nil, options: nil).first as! TableViewCell
return cell
}
func updateUIView(_ uiView: TableViewCell, context: UIViewRepresentableContext<TableViewCellPreview>) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.