美文网首页
[AR开发]报警告:将View加到SceneView中出现的线程

[AR开发]报警告:将View加到SceneView中出现的线程

作者: 沈枫_ShenF | 来源:发表于2019-05-02 01:46 被阅读0次

当将View的内容作为Material渲染给SCNNode或SCNPlane等时,会报以下警告:

[UIView setAnimationsEnabled:] being called from a background thread. Performing any operation from a background thread
> on UIView or a subclass is not supported and may result in unexpected
> and insidious behavior

比如:将UIButton作为diffuse内容。

  
  let material = SCNMaterial()

  material.diffuse.contents = self.myButton

  let plane = SCNPlane(width: width, height: height)

  plane.materials = [material]

  let node = SCNNode(geometry: plane)
  node.eulerAngles.x = -.pi / 2

  myNode.addChildNode(node)

}

我的解决方案是将button的layer作为渲染的内容:

material.diffuse.contents = self.myButton.layer

参考:

UIView Animated being called from a background thread

相关文章

网友评论

      本文标题:[AR开发]报警告:将View加到SceneView中出现的线程

      本文链接:https://www.haomeiwen.com/subject/zzpgnqtx.html