繁体   English   中英

如何在ssdk中将svg图像设置为按钮图像?

[英]How can i set svg images as button images in ios sdk?

我想将svg(可缩放矢量图形)图像设置为ipad.i中的按钮图像,以便可以将相同的图像用于ipad2,ipad3

您必须使用第三方库。 Quartz不了解SVG。

您也可以使用https://github.com/arielelkin/PocketSVG

//Step 1
CGPathRef myPath = [PocketSVG pathFromSVGFileNamed:@"icon_convidar"];

//Step 2: To display it on screen, you can create a CAShapeLayer
//and set myPath as its path property:
CAShapeLayer *shape = [CAShapeLayer layer];
shape.path = myPath;


//Step 3: Fiddle with it using CAShapeLayer's properties:
shape.strokeColor = [UIColor redColor].CGColor;
shape.lineWidth = 4;

//Step 4: Display it!
[self.btnConvidar.layer addSublayer:shape];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM