SKCropNode的工作方式是从其受影响的节点中移除其源映像未覆盖的所有内容。这是一种掩蔽,另一种是颠倒这种逻辑,并揭示源图像中没有覆盖的所有内容。
SKCropNode有一个布尔开关来设置此状态,称为invertMask,这是非常明智的。
令人讨厌的是,它似乎是私有。
如果把所有应用程序商店的审批过程、私有app的危险等都放在一边,并且接受一些有趣的测试.这只是为了测试..。
如何使用Swift将此invertMask 设置为true?
更新:
对于切面相似的问题,还有其他答案:
然而,这对我没有帮助,也不能直接回答如何在Swift中设置布尔值,这个特定的问题,这个问题。
我在这里问了一个关于选择器的问题,并接受了一个答案,这个答案告诉我,我不需要使用或理解选择器来实现这个目标:*onTarget:)
但是,似乎需要理解使用Selector所需的确切语法才能在Swift中设置此布尔值。我也不知道那是什么,也不知道怎么做。
但是,设置这个布尔值的任何其他方法(在Swift中)都是很好的。
发布于 2016-11-05 11:09:28
根据最新的Xcode 8.1 (构建8B62和苹果Swift版本3.0.1),SKCropNode.h的官方标题如下:
/**
@header
Node that can crop its children's contents with a mask
@copyright 2011 Apple, Inc. All rights reserved.
*/
#import <SpriteKit/SKNode.h>
#import <SpriteKit/SpriteKitBase.h>
NS_ASSUME_NONNULL_BEGIN
/**
A SpriteKit node that masks child nodes using another node's alpha component
*/
SK_EXPORT @interface SKCropNode : SKNode
/**
SKNode to be used as the mask.
The SKNode supplied as the mask must not be a child of another node, but it may have children. Anywhere the mask's output alpha component is less than 0.05 masks out that area for the SKCropNode's children. If the mask is nil, nothing is masked out.
*/
@property (nonatomic, retain, nullable) SKNode *maskNode;
@end
NS_ASSUME_NONNULL_END正如您所看到的,invertMask没有出现,我很抱歉,但我认为这是不可能的。
https://stackoverflow.com/questions/40436047
复制相似问题