Declaration
Initializers
One SwiftUI initializer backs <RenameButton>.
Takes no props.
Also takes the common view props: modifiers, style and testID.
Overview
A rename button receives its action from the environment. Use the
View.renameAction(_:) modifier to set the action. The
system disables the button if you don't define an action.
struct RowView: View {
@State private var text = ""
@FocusState private var isFocused: Bool
var body: some View {
TextField(text: $text) {
Text("Prompt")
}
.focused($isFocused)
.contextMenu {
RenameButton()
// ... your own custom actions
}
.renameAction { isFocused = true }
}
}When someone taps the rename button in the context menu, the rename
action focuses the text field by setting the isFocused
property to true.
You can use this button inside of a navigation title menu and the navigation title modifier automatically configures the environment with the appropriate rename action.
ContentView()
.navigationTitle($contentTitle)
.toolbarTitleMenu {
// ... your own custom actions
RenameButton()
}From Apple’s SwiftUI documentation. Code samples there are Swift.
Relationships
Conforms to
- View
See also
More in Views.
- ArrangementViewA view that arranges primary and secondary content using an adaptive layout that responds to the environment.
- ControlGroupA container view that displays semantically-related controls in a visually-appropriate manner for the context
- DividerA visual element that can be used to separate other content.
- EditButtonA button that toggles the edit mode environment value.
- EmptyViewA view that doesn't contain any content.
- GaugeA view that shows a value within a range.
- GroupA type that collects multiple instances of a content type --- like views, scenes, or commands --- into a single unit.
- GroupBoxA stylized view, with an optional label, that visually collects a logical grouping of content.
- SwipeActionsSwipe actions of a list row (SwiftUI swipeActions(edge:allowsFullSwipe:content:)). Place it inside a List.
- TimelineViewA view that updates according to a schedule that you provide.
- ViewThatFitsA view that adapts to the available space by providing the first child view that fits.