1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Xcode 15とWidgetの組み合わせで、WidgetのPaddingが変わってしまう問題の対処法

Posted at

Xcode 15で、Widgetの見た目に問題が出てきたので、それの対処法について説明します。

問題

Xcode 15コンパイルすると、iOS16以前とiOS17で見た目が大きく異なってしまうようになりました。
上下左右のpaddingが勝手に追加されてしまい、元々あったWidgetのレイアウトが崩れてしまいます。

image.png

解消法

.contentMarginsDisabled()を呼び出してあげるだけで解決できます。

struct ConecastWidget: Widget {

    let kind: String = "ConecastWidget"

    var body: some WidgetConfiguration {
        StaticConfiguration(kind: kind, provider: Provider()) { entry in
            ConecastWidgetEntryView()
        }

        .configurationDisplayName("Forcast")
        .description("See the current weather conditions and forcast for a location.")
        .supportedFamilies([.systemSmall])
        .contentMarginsDisabled()
    }
}

参考

作ってるアプリ

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?