AppleLabel - UBogun/Xojo-iosLib GitHub Wiki
Inherits from AppleView
Memory leak check: not yet done.
Status: complete
This is an implementation of UILabel, the iOS native class known to you as iOSLabel. It features all methods and properties of UILabel, giving you more control over the design of a label.
Because iOSLabel has a Handle property, there is little sense in using AppleLabel as a custom class. In most cases it will be best to use iOSLabels and extend their features by the use of the iOSLabelExtension.
AppleLabel currently uses no real custom class – the events available in iOSLabel will be sufficient in most cases. If you ever should need, you can by implementing a custom class in the ClassPtr shared property with the necessary events copied from AppleLabel’s ClassPtr.
Xojo integration
The recommended way to use AppleLabel is to stick with iOSLabel and use the features of the iOSLabelExtension module, or use the subclass iOSLabeliOSLibEnhanced for easy inspector setup. The translated properties for both are explained in the link above.
Constructor
Constructor (aRect as FoundationFrameWork.NSRect): Creates a new label with the selected dimensions.
Properties
AdjustsFontSizeToWidth As Boolean: Whether the font size should be reduced in order to fit the title string into the label’s bounding rectangle.
AllowsDefaultTighteningForTruncation As Boolean: Whether the label tightens text before truncating. Available since iOS 9.0.
AttributedCaption As AppleAttributedString: The styled text displayed by the label.
BaselineAdjustment As UIBaselineAdjustment: How text baselines are adjusted when text needs to shrink to fit in the label.
###UIBaseLineAdjustment
Value | Definition |
---|---|
Baselines | Adjust text relative to the position of its baseline. |
Centers | Adjust text based relative to the center of its bounding box. |
None | Adjust text relative to the top-left corner of the bounding box. This is the default adjustment. |
Highlighted As Boolean: Whether the control should be drawn with a highlight.
HighlightedTextColor As AppleColor: The highlight color applied to the label’s text.
LineBreakMode As NSLineBreakMode: The technique to use for wrapping and truncating the label’s text.
NSLineBreakMode
Value | Description |
---|---|
WordWrap | Wrap or clip the string only at word boundaries. This is the default wrapping option. |
CharacterWrap | Wrap or clip the string at the closest character boundary. |
Clip | Clip the text when the end of the drawing rectangle is reached. This option could result in a partially rendered character at the end of a string. |
TruncateHead | Truncate text (as needed) from the beginning of the line. For multiple lines of text, only text on the first line is truncated. |
TruncateTail | The reverse of above: The last characters at the end of the text are truncated. |
TruncateMiddle | Truncate text (as needed) from the middle of the line. For multiple lines of text, text is truncated only at the midpoint of the line. |
MinimumScaleFactor As Double: The minimum scale factor supported for the label’s text.
NumberOfLines As Integer: The maximum number of lines to use for rendering text. Default = 1. Unlimited = 0.
PreferredMaxLayoutWidth As Double: The preferred maximum width (in points) for a multiline label.
ShadowColor As AppleColor: The shadow color of the text.
ShadowOffset As Foundationframework.NSSize: The shadow offset (measured in points) for the text.
TextAlignment As NSTextAlignment: The technique to use for aligning the text.
TextColor As AppleColor: The color of the text.
TextRect As FoundationFramework.NSRect: The computed drawing rectangle for the label’s text. Convenience property calling TextRectForBounds(me.bounds, me.NumberOfLines)
Method
TextRectForBounds (aRect As FoundationFramework.NSRect, Lines As Integer) As FoundationFramework.NSRect: Returns the computed drawing rectangle for the label’s text.