3
5

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.

Qiita全国学生対抗戦Advent Calendar 2023

Day 15

【SwiftUI】ウィジェットの周りのマージンをなくす(iOS17)

Posted at

はじめに

iOS17からウィジェットの周りに余白が付くようになったみたいです。

そんな邪魔な余白をなくすってのが今回の記事の目的です。

Simulator Screenshot - iPhone 15 - 2023-12-15 at 22.29.31.png

こんな感じ

実装

struct DemoWidgetExtension: Widget {
    let kind: String = "DemoWidgetExtension"

    var body: some WidgetConfiguration {
        IntentConfiguration(
            kind: kind,
            intent: DemoWidgetConfigurationIntent.self,
            provider: Provider()
        ) { entry in
            DemoWidgetExtensionEntryView(entry: entry)
        }
+       .contentMarginsDisabled()
        .configurationDisplayName("DemoWidget")
        .description("ウィジェットの説明")
        .supportedFamilies([.systemMedium, .systemLarge])
    }
}

おわり

余白が消えましたーばんざーい

Simulator Screenshot - iPhone 15 - 2023-12-15 at 22.32.43.png

公式ドキュメント

3
5
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
3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?