如何关闭像 BubbleShowcase : UIView 这样的自定义 class?

how to close a custom class like BubbleShowcase : UIView?

我有一个class

public class BubbleShowCase: UIView {

   public func dismiss() {
        animateDisappearance()
    }
}

如何在我的视图控制器上调用关闭函数? 我想关闭自定义点击的自定义视图

无论你有什么视图 BubbleShowCase 你需要关闭的是将它从它的 superView 中删除,比如

public class BubbleShowCase: UIView {

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

如果你想制作动画,你也可以这样做

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()
    }

  }
}