8.3. Creating an Outline Around a Text Field
Problem
You want to make a border around a text field.
Solution
Set the text field’s border
property to true. Additionally, you can change the
color of the border by setting the object’s
borderColor property.
Discussion
By default, a text field lacks a visible border, which may be
desirable. For example, you may not want a border around an item
label. However, user input fields have borders by convention. The
border shows the user where to click to input a value. Simply setting
a text field’s border property to
true turns on the border around the object.
myTextField.border = true;
To turn off the border, simply set the border
property to false.
The default border color is black but can be changed by setting the
borderColor property, which accepts a hex RGB
value corresponding to the desired color:
myTextField.borderColor = 0xFF00FF; // Make the border violet.
See Also
Recipe 3.2 and Recipe 8.4
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access