iOS 13, Custom Image, title and subtitle in the presented UIActivityViewController

妖精的绣舞 提交于 2020-06-27 03:48:08

问题


I would like to know if there is any way to customise the image, title and subtitle of presented UIActivityViewController in iOS 13?


回答1:


I have found a solution using UIActivityItemSource

UIActivityItemSource have this protocol activityViewControllerLinkMetadata(_ activityViewController: UIActivityViewController) -> LPLinkMetadata?which we can use to set image title and subtitle for our UIActivityViewController

This is an example:

 public func activityViewControllerLinkMetadata(_ activityViewController: UIActivityViewController) -> LPLinkMetadata? {
    let metadata = LPLinkMetadata()

    metadata.title = "My title" // Preview Title

    // Set image 

        metadata.imageProvider = NSItemProvider(object: image)
        metadata.iconProvider = NSItemProvider(object: image)
        metadata.url = urlImage

   // Set URL for sharing 
        metadata.originalURL = myUrl // Add this if you want to have a url in your share message.

    return metadata
}

And this is the result: I have my custom image and title.




回答2:


UIActivityViewControlleris managed by ios there is no way to customize any control inside of it



来源:https://stackoverflow.com/questions/59684922/ios-13-custom-image-title-and-subtitle-in-the-presented-uiactivityviewcontroll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!