[TIL]iOS SwitUI後退ボタンの実装


struct ChangeName: View {
    @Binding var defaultName: String
    @State var changeprofileName: String = ""
    
    @Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
    
    var body: some View {
        TextField(self.defaultName, text: $changeprofileName).modifier(ClearButton(changeprofileName: $changeprofileName))
        .navigationBarTitle(LocalizedStringKey("mypage.name.title"), displayMode: .inline)
        .navigationBarBackButtonHidden(true)
        .navigationBarItems(leading:
            HStack {
            //TODO: 닉네임을 취소로 바꾸기
            Button(action: {
                self.presentationMode.wrappedValue.dismiss()
                }) {
                    Text(LocalizedStringKey("mypage.back.button"))
            }
            .foregroundColor(Color.white)
            },trailing:
                HStack {
                    Button(LocalizedStringKey("mypage.save.button"))
                    { /*code*/ }
                }
        )
    }
}
ソース
https://kka7.tistory.com/276
https://stackoverflow.com/a/59822675/15746954