【发布时间】:2018-12-03 01:38:31
【问题描述】:
我正在从服务器获取 .svg 网址。如何从 .svg url 转换 NSData 并将其转换为 UIImage。我得到像“https://storage.googleapis.com/pgcdn/ca/svg/lock.svg”这样的网址,我正在使用这个代码
NSURL *url = [NSURL URLWithString:urlString];
dispatch_queue_t callerQueue = dispatch_get_main_queue();
dispatch_queue_t downloadQueue = dispatch_queue_create("com.test.svg", NULL);
dispatch_async(downloadQueue, ^{
NSData *imageData = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:imageData];
});
此函数将图像作为 nil 值。
【问题讨论】:
-
请使用此链接:github.com/SVGKit/SVGKit
标签: ios objective-c swift cocoa-touch