此代码正确:如何斯威夫特定义MPMediaItemPropertyArtwork 3
func setInfoCenterCredentials(_ artist: String, _ title: String, _ image: UIImage) {
let mpic = MPNowPlayingInfoCenter.default()
let albumArt = MPMediaItemArtwork(image: image)
mpic.nowPlayingInfo = [MPMediaItemPropertyTitle: title,
MPMediaItemPropertyArtist: artist,
MPMediaItemPropertyArtwork: albumArt]
}
但Xcode的抱怨上:let albumArt = MPMediaItemArtwork(image: image)
,
弃用'的init(图像:)' 在iOS的10.0
我试图把image
设置为MPMediaItemPropertyArtwork: image
,但这会导致崩溃。
如何正确设置iOS 10.0?非常感谢帮助。
编辑:是的。我在文档中找到该部分:
init(boundsSize: CGSize, requestHandler: @escaping (CGSize) -> UIImage)
但我不知道如何使用它。
未删除我的问题,即使我有downvotes ...是的,我已经找到了这个,但我不知道如何处理这个。对不起,我的愚蠢问题和我的知识缺乏... –
现在你已经改变了你提问的方式,这是一个很好的问题,所以我已经收回了我的downvote。你如何使用它?我会告诉你,挂在... – matt