SwiftSVG
SwiftSVG copied to clipboard
Center SVG
I can't figure it out how to center my SVG...
The code I'm using:
let icon = UIView(SVGNamed: "icon_english") { (svgLayer) in
svgLayer.fillColor = UIColor.white.cgColor
}
icon.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5)
self.layout(icon).width(size).height(size).edges().center()
Hi @ToonvanStrijp. Without knowing too much about your icon_english SVG, can you make sure that there isn't any space around the shapes themselves? The library doesn't (and shouldn't) make assumptions about cropping any whitespace space around the graphic. Based on this, it looks like your graphic may have some extra space at the top.
You can also post the SVG file here and I'll be able to better assess the situation.