Last active
March 5, 2020 19:24
-
-
Save Koze/d7ad0b172794fd3b55fb76ebc6f03051 to your computer and use it in GitHub Desktop.
Using SwiftUI preview with UIView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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