objc2_ui_kit/generated/
UILabel.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use 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/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uilabelvibrancy?language=objc)
16// NS_ENUM
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct UILabelVibrancy(pub NSInteger);
20impl UILabelVibrancy {
21    #[doc(alias = "UILabelVibrancyNone")]
22    pub const None: Self = Self(0);
23    #[doc(alias = "UILabelVibrancyAutomatic")]
24    pub const Automatic: Self = Self(1);
25}
26
27unsafe impl Encode for UILabelVibrancy {
28    const ENCODING: Encoding = NSInteger::ENCODING;
29}
30
31unsafe impl RefEncode for UILabelVibrancy {
32    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
33}
34
35extern_class!(
36    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uilabel?language=objc)
37    #[unsafe(super(UIView, UIResponder, NSObject))]
38    #[thread_kind = MainThreadOnly]
39    #[derive(Debug, PartialEq, Eq, Hash)]
40    #[cfg(all(feature = "UIResponder", feature = "UIView"))]
41    pub struct UILabel;
42);
43
44#[cfg(all(
45    feature = "UIResponder",
46    feature = "UIView",
47    feature = "objc2-quartz-core"
48))]
49#[cfg(not(target_os = "watchos"))]
50extern_conformance!(
51    unsafe impl CALayerDelegate for UILabel {}
52);
53
54#[cfg(all(feature = "UIResponder", feature = "UIView"))]
55extern_conformance!(
56    unsafe impl NSCoding for UILabel {}
57);
58
59#[cfg(all(feature = "UIResponder", feature = "UIView"))]
60extern_conformance!(
61    unsafe impl NSObjectProtocol for UILabel {}
62);
63
64#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
65extern_conformance!(
66    unsafe impl UIAppearance for UILabel {}
67);
68
69#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
70extern_conformance!(
71    unsafe impl UIAppearanceContainer for UILabel {}
72);
73
74#[cfg(all(
75    feature = "UIContentSizeCategoryAdjusting",
76    feature = "UIResponder",
77    feature = "UIView"
78))]
79extern_conformance!(
80    unsafe impl UIContentSizeCategoryAdjusting for UILabel {}
81);
82
83#[cfg(all(feature = "UIResponder", feature = "UIView"))]
84extern_conformance!(
85    unsafe impl UICoordinateSpace for UILabel {}
86);
87
88#[cfg(all(
89    feature = "UIDynamicBehavior",
90    feature = "UIResponder",
91    feature = "UIView"
92))]
93extern_conformance!(
94    unsafe impl UIDynamicItem for UILabel {}
95);
96
97#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
98extern_conformance!(
99    unsafe impl UIFocusEnvironment for UILabel {}
100);
101
102#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
103extern_conformance!(
104    unsafe impl UIFocusItem for UILabel {}
105);
106
107#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
108extern_conformance!(
109    unsafe impl UIFocusItemContainer for UILabel {}
110);
111
112#[cfg(all(
113    feature = "UILetterformAwareAdjusting",
114    feature = "UIResponder",
115    feature = "UIView"
116))]
117extern_conformance!(
118    unsafe impl UILetterformAwareAdjusting for UILabel {}
119);
120
121#[cfg(all(feature = "UIResponder", feature = "UIView"))]
122extern_conformance!(
123    unsafe impl UIResponderStandardEditActions for UILabel {}
124);
125
126#[cfg(all(
127    feature = "UIResponder",
128    feature = "UITraitCollection",
129    feature = "UIView"
130))]
131extern_conformance!(
132    unsafe impl UITraitEnvironment for UILabel {}
133);
134
135#[cfg(all(feature = "UIResponder", feature = "UIView"))]
136impl UILabel {
137    extern_methods!(
138        #[unsafe(method(text))]
139        #[unsafe(method_family = none)]
140        pub fn text(&self) -> Option<Retained<NSString>>;
141
142        /// Setter for [`text`][Self::text].
143        ///
144        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
145        #[unsafe(method(setText:))]
146        #[unsafe(method_family = none)]
147        pub fn setText(&self, text: Option<&NSString>);
148
149        #[cfg(feature = "UIFont")]
150        #[unsafe(method(font))]
151        #[unsafe(method_family = none)]
152        pub fn font(&self) -> Option<Retained<UIFont>>;
153
154        #[cfg(feature = "UIFont")]
155        /// Setter for [`font`][Self::font].
156        ///
157        /// # Safety
158        ///
159        /// `font` might not allow `None`.
160        #[unsafe(method(setFont:))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn setFont(&self, font: Option<&UIFont>);
163
164        #[cfg(feature = "UIColor")]
165        #[unsafe(method(textColor))]
166        #[unsafe(method_family = none)]
167        pub fn textColor(&self) -> Option<Retained<UIColor>>;
168
169        #[cfg(feature = "UIColor")]
170        /// Setter for [`textColor`][Self::textColor].
171        ///
172        /// # Safety
173        ///
174        /// `text_color` might not allow `None`.
175        #[unsafe(method(setTextColor:))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn setTextColor(&self, text_color: Option<&UIColor>);
178
179        #[unsafe(method(preferredVibrancy))]
180        #[unsafe(method_family = none)]
181        pub fn preferredVibrancy(&self) -> UILabelVibrancy;
182
183        /// Setter for [`preferredVibrancy`][Self::preferredVibrancy].
184        #[unsafe(method(setPreferredVibrancy:))]
185        #[unsafe(method_family = none)]
186        pub fn setPreferredVibrancy(&self, preferred_vibrancy: UILabelVibrancy);
187
188        #[cfg(feature = "UIColor")]
189        #[unsafe(method(shadowColor))]
190        #[unsafe(method_family = none)]
191        pub fn shadowColor(&self) -> Option<Retained<UIColor>>;
192
193        #[cfg(feature = "UIColor")]
194        /// Setter for [`shadowColor`][Self::shadowColor].
195        #[unsafe(method(setShadowColor:))]
196        #[unsafe(method_family = none)]
197        pub fn setShadowColor(&self, shadow_color: Option<&UIColor>);
198
199        #[cfg(feature = "objc2-core-foundation")]
200        #[unsafe(method(shadowOffset))]
201        #[unsafe(method_family = none)]
202        pub fn shadowOffset(&self) -> CGSize;
203
204        #[cfg(feature = "objc2-core-foundation")]
205        /// Setter for [`shadowOffset`][Self::shadowOffset].
206        #[unsafe(method(setShadowOffset:))]
207        #[unsafe(method_family = none)]
208        pub fn setShadowOffset(&self, shadow_offset: CGSize);
209
210        #[cfg(feature = "NSText")]
211        #[unsafe(method(textAlignment))]
212        #[unsafe(method_family = none)]
213        pub fn textAlignment(&self) -> NSTextAlignment;
214
215        #[cfg(feature = "NSText")]
216        /// Setter for [`textAlignment`][Self::textAlignment].
217        #[unsafe(method(setTextAlignment:))]
218        #[unsafe(method_family = none)]
219        pub fn setTextAlignment(&self, text_alignment: NSTextAlignment);
220
221        #[cfg(feature = "NSParagraphStyle")]
222        #[unsafe(method(lineBreakMode))]
223        #[unsafe(method_family = none)]
224        pub fn lineBreakMode(&self) -> NSLineBreakMode;
225
226        #[cfg(feature = "NSParagraphStyle")]
227        /// Setter for [`lineBreakMode`][Self::lineBreakMode].
228        #[unsafe(method(setLineBreakMode:))]
229        #[unsafe(method_family = none)]
230        pub fn setLineBreakMode(&self, line_break_mode: NSLineBreakMode);
231
232        #[unsafe(method(attributedText))]
233        #[unsafe(method_family = none)]
234        pub fn attributedText(&self) -> Option<Retained<NSAttributedString>>;
235
236        /// Setter for [`attributedText`][Self::attributedText].
237        ///
238        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
239        #[unsafe(method(setAttributedText:))]
240        #[unsafe(method_family = none)]
241        pub fn setAttributedText(&self, attributed_text: Option<&NSAttributedString>);
242
243        #[cfg(feature = "UIColor")]
244        #[unsafe(method(highlightedTextColor))]
245        #[unsafe(method_family = none)]
246        pub fn highlightedTextColor(&self) -> Option<Retained<UIColor>>;
247
248        #[cfg(feature = "UIColor")]
249        /// Setter for [`highlightedTextColor`][Self::highlightedTextColor].
250        #[unsafe(method(setHighlightedTextColor:))]
251        #[unsafe(method_family = none)]
252        pub fn setHighlightedTextColor(&self, highlighted_text_color: Option<&UIColor>);
253
254        #[unsafe(method(isHighlighted))]
255        #[unsafe(method_family = none)]
256        pub fn isHighlighted(&self) -> bool;
257
258        /// Setter for [`isHighlighted`][Self::isHighlighted].
259        #[unsafe(method(setHighlighted:))]
260        #[unsafe(method_family = none)]
261        pub fn setHighlighted(&self, highlighted: bool);
262
263        #[unsafe(method(isUserInteractionEnabled))]
264        #[unsafe(method_family = none)]
265        pub fn isUserInteractionEnabled(&self) -> bool;
266
267        /// Setter for [`isUserInteractionEnabled`][Self::isUserInteractionEnabled].
268        #[unsafe(method(setUserInteractionEnabled:))]
269        #[unsafe(method_family = none)]
270        pub fn setUserInteractionEnabled(&self, user_interaction_enabled: bool);
271
272        #[unsafe(method(isEnabled))]
273        #[unsafe(method_family = none)]
274        pub fn isEnabled(&self) -> bool;
275
276        /// Setter for [`isEnabled`][Self::isEnabled].
277        #[unsafe(method(setEnabled:))]
278        #[unsafe(method_family = none)]
279        pub fn setEnabled(&self, enabled: bool);
280
281        #[unsafe(method(numberOfLines))]
282        #[unsafe(method_family = none)]
283        pub fn numberOfLines(&self) -> NSInteger;
284
285        /// Setter for [`numberOfLines`][Self::numberOfLines].
286        #[unsafe(method(setNumberOfLines:))]
287        #[unsafe(method_family = none)]
288        pub fn setNumberOfLines(&self, number_of_lines: NSInteger);
289
290        #[unsafe(method(adjustsFontSizeToFitWidth))]
291        #[unsafe(method_family = none)]
292        pub fn adjustsFontSizeToFitWidth(&self) -> bool;
293
294        /// Setter for [`adjustsFontSizeToFitWidth`][Self::adjustsFontSizeToFitWidth].
295        #[unsafe(method(setAdjustsFontSizeToFitWidth:))]
296        #[unsafe(method_family = none)]
297        pub fn setAdjustsFontSizeToFitWidth(&self, adjusts_font_size_to_fit_width: bool);
298
299        #[cfg(feature = "UIStringDrawing")]
300        #[unsafe(method(baselineAdjustment))]
301        #[unsafe(method_family = none)]
302        pub fn baselineAdjustment(&self) -> UIBaselineAdjustment;
303
304        #[cfg(feature = "UIStringDrawing")]
305        /// Setter for [`baselineAdjustment`][Self::baselineAdjustment].
306        #[unsafe(method(setBaselineAdjustment:))]
307        #[unsafe(method_family = none)]
308        pub fn setBaselineAdjustment(&self, baseline_adjustment: UIBaselineAdjustment);
309
310        #[cfg(feature = "objc2-core-foundation")]
311        #[unsafe(method(minimumScaleFactor))]
312        #[unsafe(method_family = none)]
313        pub fn minimumScaleFactor(&self) -> CGFloat;
314
315        #[cfg(feature = "objc2-core-foundation")]
316        /// Setter for [`minimumScaleFactor`][Self::minimumScaleFactor].
317        #[unsafe(method(setMinimumScaleFactor:))]
318        #[unsafe(method_family = none)]
319        pub fn setMinimumScaleFactor(&self, minimum_scale_factor: CGFloat);
320
321        #[unsafe(method(allowsDefaultTighteningForTruncation))]
322        #[unsafe(method_family = none)]
323        pub fn allowsDefaultTighteningForTruncation(&self) -> bool;
324
325        /// Setter for [`allowsDefaultTighteningForTruncation`][Self::allowsDefaultTighteningForTruncation].
326        #[unsafe(method(setAllowsDefaultTighteningForTruncation:))]
327        #[unsafe(method_family = none)]
328        pub fn setAllowsDefaultTighteningForTruncation(
329            &self,
330            allows_default_tightening_for_truncation: bool,
331        );
332
333        #[cfg(feature = "NSParagraphStyle")]
334        #[unsafe(method(lineBreakStrategy))]
335        #[unsafe(method_family = none)]
336        pub fn lineBreakStrategy(&self) -> NSLineBreakStrategy;
337
338        #[cfg(feature = "NSParagraphStyle")]
339        /// Setter for [`lineBreakStrategy`][Self::lineBreakStrategy].
340        #[unsafe(method(setLineBreakStrategy:))]
341        #[unsafe(method_family = none)]
342        pub fn setLineBreakStrategy(&self, line_break_strategy: NSLineBreakStrategy);
343
344        #[cfg(feature = "objc2-core-foundation")]
345        #[unsafe(method(textRectForBounds:limitedToNumberOfLines:))]
346        #[unsafe(method_family = none)]
347        pub fn textRectForBounds_limitedToNumberOfLines(
348            &self,
349            bounds: CGRect,
350            number_of_lines: NSInteger,
351        ) -> CGRect;
352
353        #[cfg(feature = "objc2-core-foundation")]
354        #[unsafe(method(drawTextInRect:))]
355        #[unsafe(method_family = none)]
356        pub fn drawTextInRect(&self, rect: CGRect);
357
358        #[cfg(feature = "objc2-core-foundation")]
359        #[unsafe(method(preferredMaxLayoutWidth))]
360        #[unsafe(method_family = none)]
361        pub fn preferredMaxLayoutWidth(&self) -> CGFloat;
362
363        #[cfg(feature = "objc2-core-foundation")]
364        /// Setter for [`preferredMaxLayoutWidth`][Self::preferredMaxLayoutWidth].
365        #[unsafe(method(setPreferredMaxLayoutWidth:))]
366        #[unsafe(method_family = none)]
367        pub fn setPreferredMaxLayoutWidth(&self, preferred_max_layout_width: CGFloat);
368
369        #[unsafe(method(enablesMarqueeWhenAncestorFocused))]
370        #[unsafe(method_family = none)]
371        pub fn enablesMarqueeWhenAncestorFocused(&self) -> bool;
372
373        /// Setter for [`enablesMarqueeWhenAncestorFocused`][Self::enablesMarqueeWhenAncestorFocused].
374        #[unsafe(method(setEnablesMarqueeWhenAncestorFocused:))]
375        #[unsafe(method_family = none)]
376        pub fn setEnablesMarqueeWhenAncestorFocused(
377            &self,
378            enables_marquee_when_ancestor_focused: bool,
379        );
380
381        /// Indicates whether expansion text will be shown when the view is too small to show all the contents. Defaults to NO.
382        #[unsafe(method(showsExpansionTextWhenTruncated))]
383        #[unsafe(method_family = none)]
384        pub fn showsExpansionTextWhenTruncated(&self) -> bool;
385
386        /// Setter for [`showsExpansionTextWhenTruncated`][Self::showsExpansionTextWhenTruncated].
387        #[unsafe(method(setShowsExpansionTextWhenTruncated:))]
388        #[unsafe(method_family = none)]
389        pub fn setShowsExpansionTextWhenTruncated(&self, shows_expansion_text_when_truncated: bool);
390
391        #[cfg(feature = "objc2-core-foundation")]
392        #[deprecated]
393        #[unsafe(method(minimumFontSize))]
394        #[unsafe(method_family = none)]
395        pub fn minimumFontSize(&self) -> CGFloat;
396
397        #[cfg(feature = "objc2-core-foundation")]
398        /// Setter for [`minimumFontSize`][Self::minimumFontSize].
399        #[deprecated]
400        #[unsafe(method(setMinimumFontSize:))]
401        #[unsafe(method_family = none)]
402        pub fn setMinimumFontSize(&self, minimum_font_size: CGFloat);
403
404        #[deprecated]
405        #[unsafe(method(adjustsLetterSpacingToFitWidth))]
406        #[unsafe(method_family = none)]
407        pub fn adjustsLetterSpacingToFitWidth(&self) -> bool;
408
409        /// Setter for [`adjustsLetterSpacingToFitWidth`][Self::adjustsLetterSpacingToFitWidth].
410        #[deprecated]
411        #[unsafe(method(setAdjustsLetterSpacingToFitWidth:))]
412        #[unsafe(method_family = none)]
413        pub fn setAdjustsLetterSpacingToFitWidth(&self, adjusts_letter_spacing_to_fit_width: bool);
414    );
415}
416
417/// Methods declared on superclass `UIView`.
418#[cfg(all(feature = "UIResponder", feature = "UIView"))]
419impl UILabel {
420    extern_methods!(
421        #[cfg(feature = "objc2-core-foundation")]
422        #[unsafe(method(initWithFrame:))]
423        #[unsafe(method_family = init)]
424        pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
425
426        /// # Safety
427        ///
428        /// `coder` possibly has further requirements.
429        #[unsafe(method(initWithCoder:))]
430        #[unsafe(method_family = init)]
431        pub unsafe fn initWithCoder(
432            this: Allocated<Self>,
433            coder: &NSCoder,
434        ) -> Option<Retained<Self>>;
435
436        #[unsafe(method(init))]
437        #[unsafe(method_family = init)]
438        pub fn init(this: Allocated<Self>) -> Retained<Self>;
439    );
440}
441
442/// Methods declared on superclass `NSObject`.
443#[cfg(all(feature = "UIResponder", feature = "UIView"))]
444impl UILabel {
445    extern_methods!(
446        #[unsafe(method(new))]
447        #[unsafe(method_family = new)]
448        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
449    );
450}