pub struct Image { /* private fields */ }Expand description
A SwiftUI Image, before it becomes a view.
The same reason Shape exists: Image has modifiers of its own that
return Image — .resizable(), .renderingMode(_:),
.symbolRenderingMode(_:) — and going through the View extensions instead
wraps it in a ModifiedContent and changes the type. Reaching them means
keeping the Image around rather than turning it into a view straight away.
Implementations§
Source§impl Image
impl Image
Sourcepub fn resizable(self) -> Self
pub fn resizable(self) -> Self
.resizable(), with the zero cap insets Swift source gets from the bare
call.
Sourcepub fn resizable_mode(self, mode: ResizingMode) -> Self
pub fn resizable_mode(self, mode: ResizingMode) -> Self
.resizable(resizingMode:)
Sourcepub fn rendering_mode(self, mode: Option<TemplateRenderingMode>) -> Self
pub fn rendering_mode(self, mode: Option<TemplateRenderingMode>) -> Self
.renderingMode(_:) — None restores the default.
Sourcepub fn symbol_rendering_mode(self, mode: Option<SymbolRenderingMode>) -> Self
pub fn symbol_rendering_mode(self, mode: Option<SymbolRenderingMode>) -> Self
.symbolRenderingMode(_:)
Examples found in repository?
examples/settings.rs (line 94)
89fn about_panel() -> View {
90 let s = settings();
91 vstack_spacing(
92 &[
93 system_image("gearshape.fill")
94 .symbol_rendering_mode(Some(views::SymbolRenderingMode::Hierarchical))
95 .view()
96 .font_size(48.0)
97 .fg_system(SystemColor::Blue),
98 text("Settings").text_style(TextStyle::Title).bold(),
99 text!("Signed in as {}", s.name.get()).fg_system(SystemColor::Gray),
100 spacer(),
101 button("Done", hide_about).button_style(views::ButtonStyle::BorderedProminent),
102 ],
103 16.0,
104 )
105 .padding(24.0)
106 .presentation_detents(&[views::PresentationDetent::Medium])
107 .presentation_drag_indicator(Visibility::Visible)
108}More examples
examples/todo.rs (line 65)
59fn row(i: usize, it: &Item) -> View {
60 hstack_spacing(
61 &[
62 // The checkmark is the button, so the whole symbol is the target.
63 button_labelled(
64 system_image(if it.done { "checkmark.circle.fill" } else { "circle" })
65 .symbol_rendering_mode(Some(views::SymbolRenderingMode::Hierarchical))
66 .view()
67 .fg_system(if it.done { SystemColor::Green } else { SystemColor::Gray }),
68 move || toggle(i),
69 )
70 .button_style(views::ButtonStyle::Bordered),
71 text(&it.title)
72 .strikethrough_styled(it.done, LinePattern::Solid, None)
73 .fg_system(if it.done { SystemColor::Gray } else { SystemColor::Primary }),
74 spacer(),
75 ],
76 10.0,
77 )
78 .padding_edges(EdgeSet::Vertical, Some(6.0))
79 .a11y_label(&it.title)
80 .a11y_value(if it.done { "Done" } else { "Not done" })
81}Sourcepub fn antialiased(self, on: bool) -> Self
pub fn antialiased(self, on: bool) -> Self
.antialiased(_:)
Sourcepub fn view(self) -> View
pub fn view(self) -> View
The image as a view, so the View modifiers can be chained after.
Examples found in repository?
examples/settings.rs (line 95)
89fn about_panel() -> View {
90 let s = settings();
91 vstack_spacing(
92 &[
93 system_image("gearshape.fill")
94 .symbol_rendering_mode(Some(views::SymbolRenderingMode::Hierarchical))
95 .view()
96 .font_size(48.0)
97 .fg_system(SystemColor::Blue),
98 text("Settings").text_style(TextStyle::Title).bold(),
99 text!("Signed in as {}", s.name.get()).fg_system(SystemColor::Gray),
100 spacer(),
101 button("Done", hide_about).button_style(views::ButtonStyle::BorderedProminent),
102 ],
103 16.0,
104 )
105 .padding(24.0)
106 .presentation_detents(&[views::PresentationDetent::Medium])
107 .presentation_drag_indicator(Visibility::Visible)
108}More examples
examples/todo.rs (line 66)
59fn row(i: usize, it: &Item) -> View {
60 hstack_spacing(
61 &[
62 // The checkmark is the button, so the whole symbol is the target.
63 button_labelled(
64 system_image(if it.done { "checkmark.circle.fill" } else { "circle" })
65 .symbol_rendering_mode(Some(views::SymbolRenderingMode::Hierarchical))
66 .view()
67 .fg_system(if it.done { SystemColor::Green } else { SystemColor::Gray }),
68 move || toggle(i),
69 )
70 .button_style(views::ButtonStyle::Bordered),
71 text(&it.title)
72 .strikethrough_styled(it.done, LinePattern::Solid, None)
73 .fg_system(if it.done { SystemColor::Gray } else { SystemColor::Primary }),
74 spacer(),
75 ],
76 10.0,
77 )
78 .padding_edges(EdgeSet::Vertical, Some(6.0))
79 .a11y_label(&it.title)
80 .a11y_value(if it.done { "Done" } else { "Not done" })
81}
82
83fn body() -> View {
84 let todos = items().lock().unwrap().clone();
85 let remaining = todos.iter().filter(|i| !i.done).count();
86
87 vstack_aligned_spacing(
88 &[
89 hstack![
90 text("Todo").text_style(TextStyle::LargeTitle).bold(),
91 spacer(),
92 text!("{remaining} left").fg_system(SystemColor::Gray),
93 ],
94 hstack_spacing(
95 &[
96 textfield_bound("What needs doing?", draft())
97 .text_field_style(views::TextFieldStyle::RoundedBorderTextFieldStyle)
98 .on_submit(SubmitTrigger::Text, add)
99 .submit_label(SubmitLabel::Done),
100 button("Add", add).button_style(views::ButtonStyle::BorderedProminent),
101 ],
102 8.0,
103 ),
104 // The empty state is a branch, so it arrives and leaves rather than
105 // appearing from nothing.
106 view_if!(
107 todos.is_empty(),
108 vstack_spacing(
109 &[
110 system_image("checkmark.seal").view().font_size(40.0)
111 .fg_system(SystemColor::Green),
112 text("Nothing left to do").fg_system(SystemColor::Gray),
113 ],
114 8.0,
115 )
116 .frame_optional(None, Some(160.0), Alignment::Center)
117 .transition(Transition::ScaleWithOpacity { scale: 0.8, anchor: (0.5, 0.5) }),
118 list(for_each_items(
119 &todos.iter().cloned().enumerate().collect::<Vec<_>>(),
120 |(i, it)| row(*i, it),
121 ))
122 .list_style(views::ListStyle::PlainListStyle)
123 ),
124 ],
125 HorizontalAlignment::Leading,
126 Some(14.0),
127 )
128 .padding(20.0)
129}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Image
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin for Image
impl UnsafeUnpin for Image
impl UnwindSafe for Image
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more