Cannot set color for a ui button
I am trying to set the color for a right ButtonItem in a view called 'table.' No matter what I set
tint_colorto, it does not seem to have an effect. I have tried different color names and hex, but the button title always shows in grey. Any idea what I'm doing wrong?
My example code:
doneButton = ui.ButtonItem(title='Done', enabled=True, tint_color='red') tableRightButtons = [doneButton] table.right_button_items = tableRightButtons
I'm sorry, that's a bug. I think it has to do with my last-minute change of the default UI font, it looks like I'm accidentally overriding other appearance options...
No worries. Thought that might be the case.
It seems that the bug only affects
ButtonItems that contain text, so if you can use an image instead, it should work as expected:
import ui v = ui.View() b = ui.ButtonItem(image=ui.Image.named('ionicons-beer-32'), tint_color='orange') v.right_button_items = [b] v.present('sheet')
Nice, and I applaud your choice of icon! Is there a full listing of the icon names anywhere?
There's a list in the UI editor when you set an image attribute (e.g. of a
ImageView). When you do this in code, you have to append the size though ('-24, '-32', or '-256').