Skip to content

SVGView doesn't fit the image in the screen with contentMode ".scaleAspectFit" #776

@aram-azbekian

Description

@aram-azbekian

Hi! I have a small project where I'm trying to open SVG image using Macaw library. In that project I make a SVGView and set its contentMode parameter to ".scaleAspectFit". As far as I know, the only condition for it to work is availability of "width" and "height" parameters in SVG XML. But it just doesn't work and the image is presented in its original scale

So, this is a code snippet where I create a view:

func makeUIView(context: Context) -> SVGView {
        let node = try! SVGParser.parse(resource: svgName)
        let svgView = SVGView(node: node, frame: CGRect(origin: CGPoint.zero, size: size))
        svgView.backgroundColor = UIColor.white
        svgView.contentMode = .scaleAspectFit
        svgView.layer.borderWidth = 1.0
        svgView.layer.borderColor = UIColor.white.cgColor
        svgView.zoom.enable()
        
        return svgView
}

and attached below is the image example from the project

Thanks in advance. Let me know if you need anything else.
svg-5.svg.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions