diff --git a/changes/3104.misc.rst b/changes/3104.misc.rst new file mode 100644 index 0000000000..e7e09e3d62 --- /dev/null +++ b/changes/3104.misc.rst @@ -0,0 +1 @@ +The default background color of `toga.Label` on iOS now correctly displays a transparent background, instead of a black background. diff --git a/iOS/src/toga_iOS/widgets/base.py b/iOS/src/toga_iOS/widgets/base.py index b0ff57ab39..8284a25d35 100644 --- a/iOS/src/toga_iOS/widgets/base.py +++ b/iOS/src/toga_iOS/widgets/base.py @@ -13,6 +13,10 @@ def __init__(self, interface): self.native = None self.create() + # Override this attribute to set a different default background + # color for a given widget. + self._default_background_color = self.native.backgroundColor + @abstractmethod def create(self): ... @@ -87,7 +91,9 @@ def set_color(self, color): pass def set_background_color(self, color): - self.native.backgroundColor = None if color is None else native_color(color) + self.native.backgroundColor = ( + self._default_background_color if color is None else native_color(color) + ) # INTERFACE def add_child(self, child):