objc2_ui_kit/generated/
UISwitch.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9#[cfg(feature = "objc2-quartz-core")]
10#[cfg(not(target_os = "watchos"))]
11use objc2_quartz_core::*;
12
13use crate::*;
14
15#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct UISwitchStyle(pub NSInteger);
20impl UISwitchStyle {
21 #[doc(alias = "UISwitchStyleAutomatic")]
22 pub const Automatic: Self = Self(0);
23 #[doc(alias = "UISwitchStyleCheckbox")]
24 pub const Checkbox: Self = Self(1);
25 #[doc(alias = "UISwitchStyleSliding")]
26 pub const Sliding: Self = Self(2);
27}
28
29unsafe impl Encode for UISwitchStyle {
30 const ENCODING: Encoding = NSInteger::ENCODING;
31}
32
33unsafe impl RefEncode for UISwitchStyle {
34 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
35}
36
37extern_class!(
38 #[unsafe(super(UIControl, UIView, UIResponder, NSObject))]
40 #[thread_kind = MainThreadOnly]
41 #[derive(Debug, PartialEq, Eq, Hash)]
42 #[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
43 pub struct UISwitch;
44);
45
46#[cfg(all(
47 feature = "UIControl",
48 feature = "UIResponder",
49 feature = "UIView",
50 feature = "objc2-quartz-core"
51))]
52#[cfg(not(target_os = "watchos"))]
53extern_conformance!(
54 unsafe impl CALayerDelegate for UISwitch {}
55);
56
57#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
58extern_conformance!(
59 unsafe impl NSCoding for UISwitch {}
60);
61
62#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
63extern_conformance!(
64 unsafe impl NSObjectProtocol for UISwitch {}
65);
66
67#[cfg(all(
68 feature = "UIAppearance",
69 feature = "UIControl",
70 feature = "UIResponder",
71 feature = "UIView"
72))]
73extern_conformance!(
74 unsafe impl UIAppearance for UISwitch {}
75);
76
77#[cfg(all(
78 feature = "UIAppearance",
79 feature = "UIControl",
80 feature = "UIResponder",
81 feature = "UIView"
82))]
83extern_conformance!(
84 unsafe impl UIAppearanceContainer for UISwitch {}
85);
86
87#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
88extern_conformance!(
89 unsafe impl UICoordinateSpace for UISwitch {}
90);
91
92#[cfg(all(
93 feature = "UIControl",
94 feature = "UIDynamicBehavior",
95 feature = "UIResponder",
96 feature = "UIView"
97))]
98extern_conformance!(
99 unsafe impl UIDynamicItem for UISwitch {}
100);
101
102#[cfg(all(
103 feature = "UIControl",
104 feature = "UIFocus",
105 feature = "UIResponder",
106 feature = "UIView"
107))]
108extern_conformance!(
109 unsafe impl UIFocusEnvironment for UISwitch {}
110);
111
112#[cfg(all(
113 feature = "UIControl",
114 feature = "UIFocus",
115 feature = "UIResponder",
116 feature = "UIView"
117))]
118extern_conformance!(
119 unsafe impl UIFocusItem for UISwitch {}
120);
121
122#[cfg(all(
123 feature = "UIControl",
124 feature = "UIFocus",
125 feature = "UIResponder",
126 feature = "UIView"
127))]
128extern_conformance!(
129 unsafe impl UIFocusItemContainer for UISwitch {}
130);
131
132#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
133extern_conformance!(
134 unsafe impl UIResponderStandardEditActions for UISwitch {}
135);
136
137#[cfg(all(
138 feature = "UIControl",
139 feature = "UIResponder",
140 feature = "UITraitCollection",
141 feature = "UIView"
142))]
143extern_conformance!(
144 unsafe impl UITraitEnvironment for UISwitch {}
145);
146
147#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
148impl UISwitch {
149 extern_methods!(
150 #[cfg(feature = "UIColor")]
151 #[unsafe(method(onTintColor))]
152 #[unsafe(method_family = none)]
153 pub unsafe fn onTintColor(&self) -> Option<Retained<UIColor>>;
154
155 #[cfg(feature = "UIColor")]
156 #[unsafe(method(setOnTintColor:))]
158 #[unsafe(method_family = none)]
159 pub unsafe fn setOnTintColor(&self, on_tint_color: Option<&UIColor>);
160
161 #[cfg(feature = "UIColor")]
162 #[unsafe(method(thumbTintColor))]
163 #[unsafe(method_family = none)]
164 pub unsafe fn thumbTintColor(&self) -> Option<Retained<UIColor>>;
165
166 #[cfg(feature = "UIColor")]
167 #[unsafe(method(setThumbTintColor:))]
169 #[unsafe(method_family = none)]
170 pub unsafe fn setThumbTintColor(&self, thumb_tint_color: Option<&UIColor>);
171
172 #[cfg(feature = "UIImage")]
173 #[unsafe(method(onImage))]
174 #[unsafe(method_family = none)]
175 pub unsafe fn onImage(&self) -> Option<Retained<UIImage>>;
176
177 #[cfg(feature = "UIImage")]
178 #[unsafe(method(setOnImage:))]
180 #[unsafe(method_family = none)]
181 pub unsafe fn setOnImage(&self, on_image: Option<&UIImage>);
182
183 #[cfg(feature = "UIImage")]
184 #[unsafe(method(offImage))]
185 #[unsafe(method_family = none)]
186 pub unsafe fn offImage(&self) -> Option<Retained<UIImage>>;
187
188 #[cfg(feature = "UIImage")]
189 #[unsafe(method(setOffImage:))]
191 #[unsafe(method_family = none)]
192 pub unsafe fn setOffImage(&self, off_image: Option<&UIImage>);
193
194 #[unsafe(method(title))]
198 #[unsafe(method_family = none)]
199 pub unsafe fn title(&self) -> Option<Retained<NSString>>;
200
201 #[unsafe(method(setTitle:))]
203 #[unsafe(method_family = none)]
204 pub unsafe fn setTitle(&self, title: Option<&NSString>);
205
206 #[unsafe(method(style))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn style(&self) -> UISwitchStyle;
210
211 #[unsafe(method(preferredStyle))]
213 #[unsafe(method_family = none)]
214 pub unsafe fn preferredStyle(&self) -> UISwitchStyle;
215
216 #[unsafe(method(setPreferredStyle:))]
218 #[unsafe(method_family = none)]
219 pub unsafe fn setPreferredStyle(&self, preferred_style: UISwitchStyle);
220
221 #[unsafe(method(isOn))]
222 #[unsafe(method_family = none)]
223 pub unsafe fn isOn(&self) -> bool;
224
225 #[unsafe(method(setOn:))]
227 #[unsafe(method_family = none)]
228 pub unsafe fn setOn(&self, on: bool);
229
230 #[cfg(feature = "objc2-core-foundation")]
231 #[unsafe(method(initWithFrame:))]
232 #[unsafe(method_family = init)]
233 pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
234
235 #[unsafe(method(initWithCoder:))]
236 #[unsafe(method_family = init)]
237 pub unsafe fn initWithCoder(
238 this: Allocated<Self>,
239 coder: &NSCoder,
240 ) -> Option<Retained<Self>>;
241
242 #[unsafe(method(setOn:animated:))]
243 #[unsafe(method_family = none)]
244 pub unsafe fn setOn_animated(&self, on: bool, animated: bool);
245 );
246}
247
248#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
250impl UISwitch {
251 extern_methods!(
252 #[cfg(all(
253 feature = "UIAction",
254 feature = "UIMenuElement",
255 feature = "objc2-core-foundation"
256 ))]
257 #[unsafe(method(initWithFrame:primaryAction:))]
259 #[unsafe(method_family = init)]
260 pub unsafe fn initWithFrame_primaryAction(
261 this: Allocated<Self>,
262 frame: CGRect,
263 primary_action: Option<&UIAction>,
264 ) -> Retained<Self>;
265 );
266}
267
268#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
270impl UISwitch {
271 extern_methods!(
272 #[unsafe(method(init))]
273 #[unsafe(method_family = init)]
274 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
275
276 #[unsafe(method(new))]
277 #[unsafe(method_family = new)]
278 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
279 );
280}