0
1

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でよくあるSecondoryButtonを実装

Posted at

はじめに

今回はよくある部品としてSecondary Buttonがあると思いますが、それを実装していきます。

コード

struct SecondaryButton: View {
    var title: String
    var action: () -> Void

    var body: some View {
        Button(action: action) {
            ZStack {
                Capsule()
                    .fill(Color.white)
                    .frame(height: 60)
                Capsule()
                    .stroke(Color.rjOrange500, lineWidth: 2)
                    .frame(height: 60)
                    .overlay {
                        Text(title)
                            .font(.bold16)
                            .foregroundStyle(Color.rjOrange500)
                    }
            }
        }
    }
}

最後に

SwiftUiで背景色を設定したButtonを使おうとしたところ、うまくできずZStackで部品同士を重ねて再現するしかできなかったのでこのような実装にしました

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?