-1

i have a class

public class BubbleShowCase: UIView {

   public func dismiss() {
        animateDisappearance()
    }
}

how can i call that dismiss function on my View Controller ? i want to dismiss that custom view on custom tap

amaulana
  • 97
  • 1
  • 8

1 Answers1

1

whatever view you have BubbleShowCase what you need to dismiss is to remove it from its superView like

public class BubbleShowCase: UIView {

    public func dismiss() {
        self.removeFromSuperview()
     }
 }

and if you want to animate it you can do that as well

public class BubbleShowCase: UIView {
  
    public func dismiss() {
        UIView.animate(withDuration: 0.5, delay: duration, animations: {
        self.alpha = 0
    }) { (completed) in
        guard completed else { return }
        self.removeFromSuperview()
    }

  }
}
Jawad Ali
  • 13,556
  • 3
  • 32
  • 49