在xcode7上出错了。 view.layer.renderInContext(背景!)

时间:2016-01-20 11:18:18

标签: swift xcode7

错误说“可选类型的值'CGContext?'没打开;你的意思是用'!'还是'?'?“。

有谁知道如何解决这个问题?

       view.layer.renderInContext(context!)

1 个答案:

答案 0 :(得分:0)

如果该行提供了该错误,则context必须是CGContext??类型。

正如错误所述,您可以使用!?来解包表达式context!中的可选结果。