首页 > 解决方案 > 如何在 Swift 4 中隐藏默认的 GSMapView InfoWindowOfMarker UIView 框架?

问题描述

我有一个我决定稍后使用的以编程方式创建的 UIView。但是,它现在在导航逻辑中被调用,我不想更改逻辑,因为我将在第二个版本中介绍此预览版。问题是我被一个默认框架卡住了,我无法移动到屏幕之外或将大小更改为零或隐藏。

这是代码中的类,我附上了这个丑陋的白色默认框架的图片,我需要以某种方式隐藏。我尝试了很多带有约束、透明度等的选项,但它仍然存在。有人可以给建议吗?

class PointPreview: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
   }
}

在此处输入图像描述

标签: swift

解决方案


您是否尝试过将另一个视图(看起来像从您的图像中猜测的地图)放在白色视图前面?

你可以这样做:

class ViewController: UIViewController{
   override func viewDidLoad() {
      let pointPreview = PointPreview()
      let otherView = UIView()
      self.view.addSubview(otherView)
      self.view.addSubview(pointPreview)
      self.view.bringSubviewToFront(otherView) //this makes the otherView(map) go in front of the pointPreview
   }
}

推荐阅读