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?

SwiftUIで自前のタイトルバーをつくる

Posted at

はじめに

今回はSwiftUIをつかって自前のタイトルバーを作っていきます

コード

ZStack {
    HStack {
        Button(action: {
            dismiss()
        }) {
            Image("arrow_back")
                .resizable()
                .foregroundStyle(Color.AccentColor)
                .frame(width: 24, height: 24)
            }
            .frame(width: 24, height: 24)
            .padding(.leading, 20)

         Spacer()
    }
    .frame(maxWidth: .infinity, alignment: .leading)
    Text("title")
        .font(.headline)
        .frame(maxWidth: .infinity, alignment: .center)
}

最後に

NavigationStackで遷移した時などに自動で表示してくれるものがあったり、それを非表示にする設定があったりはしますが、用意されてる分自由に使うには結局自前で実装したほうが使い勝手が良かったのでつくりました
どなたかのお役に立てれば幸いです

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?