How to create a UIButton for tvOS with a clear background color?
Asked Answered
F

2

10

I'm trying to create a UIButton of System type with a clear background color. The problem is that it shows a gray background color even if I set it to clearColor. I can do it with a Custom type UIButton, but then the button loses the default effects for focusing and selection.

Appearance of the System UIButton with a clear background color

Does anyone knows how to create a System UIButton with a entirely transparent background?

Fries answered 30/9, 2015 at 16:19 Comment(3)
did you resolve this?Traynor
I didn't, ended up having to create a custom UIButton and implemented the highlight effect myself.Fries
It would helpful to others if you shared the code of the subclass of UIButton that you ended up using.Nerveracking
C
8

Since tvOS 11 there is a solution for that using the button type "plain" instead of "system" without loosing the effects for focusing and selection:

  1. Open the button properties in the Interface builder an select "Type"->"Plain"Button Properties

  2. Set the button background color to "clear color"

Thats it.

Watch Apples Video about "UIButtonTypePlain" here (starts at 13:44): UIButtonTypePlain explained

Champagne answered 28/11, 2018 at 10:12 Comment(1)
this destroys the TVOS scroll speed for horizontal items in HStack / LazyHGridLecher
S
-3

In storyboard Attributes Inspector you have to change button type System to Custom.

Strake answered 3/10, 2015 at 5:59 Comment(1)
he specifically states that he wants a System UIButton.Traynor

© 2022 - 2024 — McMap. All rights reserved.