【发布时间】:2012-04-06 20:27:27
【问题描述】:
我想将 svg(可缩放矢量图形)图像设置为 ipad 中的按钮图像。这样我就可以为 ipad2、ipad3 使用相同的图像
【问题讨论】:
-
user1285498:请使用这个问题,因为您的重复问题应该在适当的时候关闭。根据我对您的其他问题的 cmets,您能在这里告诉我们您在网上尝试过什么来回答这个问题吗?你检查过官方的 iOS 文档吗?
我想将 svg(可缩放矢量图形)图像设置为 ipad 中的按钮图像。这样我就可以为 ipad2、ipad3 使用相同的图像
【问题讨论】:
您必须使用third party 库。 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];
【讨论】: