First when I tested your solution it did not work as expected, but I tried a little bit around.
First thing I should mention is, that I'm using Multi-OS-Engine, so the code that did the right thing for me is written in pure Java, but it should also work with your swift-solution.
This is the solution which worked for me after all, I replaced the point inside test by the hit test:
import org.moe.natj.general.Pointer;
import org.moe.natj.general.ann.Owned;
import org.moe.natj.general.ann.RegisterOnStartup;
import org.moe.natj.objc.ObjCRuntime;
import org.moe.natj.objc.ann.ObjCClassName;
import org.moe.natj.objc.ann.Selector;
import apple.coregraphics.struct.CGPoint;
import apple.uikit.UICollectionViewCell;
import apple.uikit.UIEvent;
import apple.uikit.UIView;
@org.moe.natj.general.ann.Runtime(ObjCRuntime.class)
@ObjCClassName("UICustomCollectionViewCell")
@RegisterOnStartup
public class UICustomCollectionViewCell extends UICollectionViewCell {
protected UICustomCollectionViewCell(Pointer peer) {
super(peer);
}
/**
* @noinspection JniMissingFunction
*/
@Owned
@Selector("alloc")
public static native UICustomCollectionViewCell alloc();
/**
* @noinspection JniMissingFunction
*/
@Selector("init")
public native UICustomCollectionViewCell init();
@Override
public UIView hitTestWithEvent(CGPoint point, UIEvent event) {
for (UIView subview : subviews()) {
if (!subview.isHidden() &&
subview.isUserInteractionEnabled()) {
return subview.hitTestWithEvent(convertPointToView(point, subview), event);
}
}
return super.hitTestWithEvent(point, event);
}
}
Thanks for your help! Without it I would not have solved this issue I have had for days. Maybe you want to edit your answer to also use hit test.