是否可以加载.ai文件并以编程方式打开它们?
这就是我的尝试:
- (IBAction)openDocument:(id)sender
{
QLPreviewController *previewController = [[QLPreviewController alloc] init];
[previewController setDataSource:self];
[previewController setDelegate:self];
[self presentModalViewController:previewController animated:YES];
}
- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller
{
return 1;
}
- (id <QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index
{
return [[NSBundle mainBundle] URLForResource:@"CNW EXPLODED1" withExtension:@"ai"];
}
但输出是这样的:
答案 0 :(得分:4)
有一种方法可以做到这一点。这就是将ai的扩展名改为pdf并加载,如下所示,
- (IBAction)openDocument:(id)sender
{
QLPreviewController *previewController = [[QLPreviewController alloc] init];
[previewController setDataSource:self];
[previewController setDelegate:self];
[self presentModalViewController:previewController animated:YES];
}
- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller
{
return 1;
}
- (id <QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index
{
return [[NSBundle mainBundle] URLForResource:@"CNW EXPLODED1" withExtension:@"pdf"];
}
**
- (IBAction)openDocument:(id)sender
{
UIButton *button = (UIButton *)sender;
NSURL *URL = [[NSBundle mainBundle] URLForResource:@"CNW EXPLODED1" withExtension:@"ai"];
if (URL) {
// Initialize Document Interaction Controller
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL];
// Configure Document Interaction Controller
[self.documentInteractionController setDelegate:self];
// Present Open In Menu
[self.documentInteractionController presentOpenInMenuFromRect:[button frame] inView:self.view animated:YES];
}
}
- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller {
return self;
}
**
答案 1 :(得分:0)
如果将Illustrator文件保存为.eps文件,则可以提取矢量详细信息并将其重新用作CAShapeLayer上的路径,但它对于复杂形状并不简单。
这些链接应该有所帮助:
http://rdsquared.wordpress.com/2012/01/10/svg-to-coregraphics-conversion/
肯定在Github上搜索SVGKit。
希望有所帮助。向下来的人们致敬。