今天小部件缩进/不使用全部 space

Today Widget indented / doesn't use all space

在 iOS 中构建今日小部件,我的视图没有占据整个屏幕宽度:

在上面的屏幕截图中看到,超出屏幕该点的任何内容都会被截断。

我已经使用 Today Widget 扩展程序提供的标准故事板进行了设置:

这让我感到困惑,因为我看到很多其他应用程序的 Today 扩展使用了整个屏幕宽度。

你需要像这样实现widgetMarginInsetsForProposedMarginInsets:

   func widgetMarginInsetsForProposedMarginInsets(defaultMarginInsets: UIEdgeInsets) -> UIEdgeInsets {
      return UIEdgeInsetsZero
    }

检查Apple Doc - Design the UI