MPMediaItemArtwork init(image :)在iOS 10.0中已弃用 [英] MPMediaItemArtwork init(image:) deprecated in iOS 10.0

查看:1491
本文介绍了MPMediaItemArtwork init(image :)在iOS 10.0中已弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apple已弃用iOS 10中 MPMediaItemArtwork 中的 init(image:)方法。
什么是新的选择。

Apple has deprecated init(image:) method in MPMediaItemArtwork in iOS 10. What is the new alternative.

该类显示接口显示以下方法,以便在新操作系统版本中可用

the class shows interface shows method below to be available in the new OS version

public init(boundsSize: CGSize, requestHandler: @escaping (CGSize) -> UIImage)

任何人都知道如何使用它?

Anyone know how to use it?

同样问题2,上一个问题的一部分:在锁上显示正在播放元数据 - 屏幕和控制中心使用 MPNowPlayingInfoCenter 在模拟器中工作?

Also question 2, part of the previous question: Does showing now playing metadata on the lock-screen and control-center using MPNowPlayingInfoCenter work in the simulator?

推荐答案

您可以使用以下代码:

let image = UIImage(named: "logo")!
let artwork = MPMediaItemArtwork.init(boundsSize: image.size, requestHandler: { (size) -> UIImage in
        return image
})

而且,是的,正在播放模拟器中控制中心的元数据显示。

And, yes, "now playing" metadata shows on the control center in the simulator.

这篇关于MPMediaItemArtwork init(image :)在iOS 10.0中已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆