I am adding an ARCoachingOverlayView to my ARView like this
let coachingOverlayTemp = ARCoachingOverlayView()
coachingOverlayTemp.delegate = self
coachingOverlayTemp.session = self.session
coachingOverlayTemp.goal = .horizontalPlane
coachingOverlayTemp.activatesAutomatically = true
coachingOverlayTemp.translatesAutoresizingMaskIntoConstraints = false
self.addSubview(coachingOverlayTemp)
coachingOverlay = coachingOverlayTemp // I store it to a variable on the class
Later, If I do
coachingOverlay.activatesAutomatically = false
has no effect. coachingOverlay continues to work normally.
How do I disable it immediately when I want?
An instance method setActive(_:animated:) controls whether coaching is in progress or not.
open func setActive(_ active: Bool, animated: Bool)
Here's what Apple documentation says:
If the animated property of
setActive(_:animated:)is true,isActiveandisHiddenare false while the coaching overlay is fading out. When the coaching overlay is deactivated without animation, or when the animation finishes, ARKit notifies you by callingcoachingOverlayViewDidDeactivate(_:).
// SMOOTHLY
ARCoachingOverlayView().setActive(false, animated: false)
Or as alternative you can use isHidden property:
// ABRUPTLY
ARCoachingOverlayView().isHidden = true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With