Private Boolean: how to set on SKCropNode, with Swift?

六月ゝ 毕业季﹏ 提交于 2019-12-24 08:12:26

问题


SKCropNode works by removing every thing from its affected nodes that are not covered by its source image. This is one type of masking, the other is to invert this logic, and reveal everything that's not covered by the source image.

SKCropNode has a boolean switch to set this state, called invertMask, sensibly enough.

What's annoying is that it's seemingly private.

If putting aside all the app store approval processes, dangers of private APIs, etc, and accepting that it's something interesting to test... and this is only for the purposes of testing...

How do I set this invertMask to true, with Swift?

UPDATE:

There are other answers to tangentially similar questions:

How to access iOS private APIs in Swift?

However that doesn't help me, nor is it a direct answer to how to do it for setting a boolean, this particular one, in this particular question, in Swift.

I've asked a question about Selectors here, and accepted an answer that showed me I didn't need to use or understand Selectors in order to achieve that goal: What is a selector in SKAction: perform(_:onTarget:)

But it looks like understanding the exact syntax required to use a Selector might be required to set this boolean in Swift. I don't know what that is, or how to do it, either.

But any other means of setting this boolean (in Swift) is certainly fine.


回答1:


According to the latest Xcode 8.1 (build 8B62 with Apple Swift version 3.0.1) the official SKCropNode.h header is this below:

/**
 @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

As you can see there is no presence about invertMask, I'm sorry but I think this is no possible.



来源:https://stackoverflow.com/questions/40436047/private-boolean-how-to-set-on-skcropnode-with-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!