Skip to content

Commit 8a02735

Browse files
authored
Correct handling of default widget background color for label (#3104)
Explicitly use the default background color, rather than None as a reset value.
1 parent 58d0d02 commit 8a02735

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

changes/3104.misc.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The default background color of `toga.Label` on iOS now correctly displays a transparent background, instead of a black background.

iOS/src/toga_iOS/widgets/base.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ def __init__(self, interface):
1313
self.native = None
1414
self.create()
1515

16+
# Override this attribute to set a different default background
17+
# color for a given widget.
18+
self._default_background_color = self.native.backgroundColor
19+
1620
@abstractmethod
1721
def create(self): ...
1822

@@ -87,7 +91,9 @@ def set_color(self, color):
8791
pass
8892

8993
def set_background_color(self, color):
90-
self.native.backgroundColor = None if color is None else native_color(color)
94+
self.native.backgroundColor = (
95+
self._default_background_color if color is None else native_color(color)
96+
)
9197

9298
# INTERFACE
9399
def add_child(self, child):

0 commit comments

Comments
 (0)