Forum Archive

Label corner radius not doing anything

donnieh

I change a button's corner radius just fine. Why won't a label's corner radius change? Do I have to do something special with the border or frame first?

lbl = ui.Label()
lbl.frame = (20,20,100,100)
lbl.corner_radius = (5)
brumm

You also need

lbl.border_width = 1
donnieh

Thank you, this helped. The results were not as expected though (my fault). A border with a radius was indeed created; however, the sharp white label corners were still present as well. Hmmm

My solution was to use a text view and that worked better.

JonB

Looks like a bug to me.

donnieh

Here is what I mean:
alt text

omz

The reason is basically that labels don't clip their content by default (I think this has changed in iOS 8 due to improved support for some Asian languages), and there's currently no way to change that (well, in the 1.6 you could technically do it via ctypes, but it requires quite a lot of code...) The easiest workaround would be to embed a label in a ui.View (i.e. make it a subview of a view that clips).