加载Adobe Illustrator(.ai)文件
是否有可能加载.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"];
}
但输出是这样的:
有一种方法可以做到这一点。 这正在改变这个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"];
}
OUTPUT:
这是完美的工作..但我不想改变扩展。 任何人都可以帮助我更多。
**
更新答案:
- (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;
}
这显示菜单选项,但与选项BUMP。 它仅适用于设备
**
如果将Illustrator文件保存为.eps文件,但可以提取矢量细节,并将它们重新用作CAShapeLayer上的路径,但对于复杂的形状不是直接的。
这些链接应该有帮助:
http://jeffmenter.wordpress.com/2011/04/17/method-for-interpreting-illustrator-art-assets-as-cocoa-cgpathref/
http://rdsquared.wordpress.com/2012/01/10/svg-to-coregraphics-conversion/
绝对在Github上搜索SVGKit。
希望有所帮助。 荣耀归于downvoters。
链接地址: http://www.djcxy.com/p/13707.html上一篇: Loading Adobe Illustrator(.ai) file
下一篇: C++11 Can only primitive data types be declared atomic?