Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我PencilKit在我的应用程序中使用并让我的用户在PKCanvasView. 但我不希望他们能够保存空白图纸。所以我需要检查是否PKDrawing为空白(除了透明像素之外不包含任何内容)。我在官方文档中找不到任何具体的方法。
PencilKit
PKCanvasView
PKDrawing
我尝试将其转换PKDrawing为Data并检查它是否为空,但即使图纸为空白,情况也并非如此。
Data
有没有一种方便的方法来检查PKDrawingorPKCanvasView是否为空?
或者,有没有办法检查是否UIImage只包含透明像素?
UIImage
您可以简单地检查是否有东西在绘制
if canvasView.drawing.bounds.isEmpty { print("nothing has been drawn so far") } else { // task which you can want to do with your drawing }