我的源代码非常简单,如下所示:
//
// SVGImage.swift
// WorldRoad
//
// Created by norains on 2019/11/26.
// Copyright © 2019 norains. All rights reserved.
//
import PocketSVG
import SwiftUI
struct SVGImage: UIViewRepresentable {
func makeUIView(context: Context) -> SVGImageView {
let url = Bundle.main.url(forResource: "tiger", withExtension: "svg")!
let svgImageView = SVGImageView.init(contentsOf: url)
//svgImageView.frame = view.bounds //Could not set the frame here
svgImageView.contentMode = .scaleAspectFit
return svgImageView
}
func updateUIView(_ view: SVGImageView, context: Context) {
}
}
struct SVGImage_Previews: PreviewProvider {
static var previews: some View {
return SVGImage()
}
}
看起来视图比屏幕大。
我该怎么办?谢谢!