Open longjianjiang opened 5 years ago
I put a svg file named test.svg in the main bundle, and its contents are:
<?xml version="1.0" encoding="UTF-8"?>
<svg width="40px" height="40px" viewBox="0 0 40 40" version="1.1" preserveAspectRatio="xMinYMin meet" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="border:1px solid #7798CB">
<circle cx="20" cy="20" r="20" stroke="green" stroke-width="4" fill="yellow" />
</svg>
then i use code to display this svg content:
let svgView = UIView(SVGNamed: "test")
svgView.frame = CGRect(x: 0, y: 100, width: 100, height: 100)
view.addSubview(svgView)
it does not display correct color, svg display as a black circle instead of yellow circle with green border.
try HEXcolor instead of color name.
Can we provide a interface just receive
.svg
file string like below:Then we can get a view or layer that this svg file represent.