[英]Set UIButton Image with SVG file
我正在尝试使用SVG文件设置UIBUtton的图像...单击按钮的效果很好,但它看起来不可见。 我正在尝试使用PocketSVG: https : //github.com/arielelkin/PocketSVG
我正在尝试:
CGPathRef myPath = [PocketSVG pathFromSVGFileNamed:@"icon_convidar.svg"];
//2: To display it on screen, you can create a CAShapeLayer
//and set myPath as its path property:
CAShapeLayer *myShapeLayer = [CAShapeLayer layer];
myShapeLayer.path = myPath;
//3: Fiddle with it using CAShapeLayer's properties:
myShapeLayer.strokeColor = [[UIColor greenColor] CGColor];
myShapeLayer.lineWidth = 4;
myShapeLayer.fillColor = [[UIColor greenColor] CGColor];
//4: Display it!
[self.btnConvidar.layer addSublayer:myShapeLayer];
我只重写了这一行:
CGPathRef myPath = [PocketSVG pathFromSVGFileNamed:@"icon_convidar.svg"];
与以下行:
CGPathRef myPath = [PocketSVG pathFromSVGFileNamed:@"icon_convidar"];
您无法使用SVG,因为iOS不支持XML或SVG。 PDF可以使用。 这是我找到的关于该主题的最佳教程: https : //useyourloaf.com/blog/xcode-9-vector-images/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.