UIActivityItemSource在后台渲染图像

时间:2016-03-14 15:39:45

标签: ios swift uikit grand-central-dispatch

我的应用程序需要大约10秒才能渲染出应用了许多滤镜的全分辨率图像。我想允许用户保存或使用UIActivityViewController分享。我已经将UIActivityItemSource子类化,因此它会在活动视图打开时提供缩略图。

如何制作,以便我的素材来源在后台渲染图片?具体来说,我想允许视图控制器最小化并显示进度条。

我已经有进度条工作,我只需要知道如何在后台执行以下操作:

func activityViewController(activityViewController: UIActivityViewController, itemForActivityType activityType: String) -> AnyObject? {

    // this step takes 10 seconds
    // is there any way to do it in the background?
    // So: the activity view can minimize
    // and the main thread is free to update my progress bar

    let image = renderFullImage()

    return image
}

1 个答案:

答案 0 :(得分:0)

诀窍是使用 //place this inside of your animate function as a property complete:function() { $(id).css("background-color", "#78FF81"); }); 代替UIActivityItemProvider。您应该覆盖已在后台调用的UIActivityItemSource方法。

相关问题