0
2

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.

【SwiftUI】NavigationBarに背景画像を設定

Posted at

サンプル素材

12133

Kjpargeter - jp.freepik.com によって作成された background ベクトル

タイトル画像の表示方法

実装

import SwiftUI

struct ContentView: View {
+   init() {
+       let appearance = UINavigationBarAppearance()
+       appearance.backgroundImage = UIImage(named: "12133")
+       UINavigationBar.appearance().standardAppearance = appearance
+       UINavigationBar.appearance().compactAppearance = appearance
+       UINavigationBar.appearance().scrollEdgeAppearance = appearance
+   }
    var body: some View {
        NavigationView {
            Text("Hello, world!")
+               .navigationBarTitleDisplayMode(.inline)
        }
    }
}

完成系

simulator_screenshot_940E301C-6F8D-4EC7-9BA1-813A25347FAF.png

おわり

結構やり方迷いました

0
2
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
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?