There's a shadow on my button

前端 未结 3 1150
既然无缘
既然无缘 2021-01-05 11:10

i\'m creating a button programmaticly for an iPad application. when i see the button, there looks to be a shadow type thing below it. what is it and how can i get rid of it?

3条回答
  •  误落风尘
    2021-01-05 11:45

    On iPads, a rounded-rect UIButton always draws a white line along its bottom edge. You can't see that white line if the button's superview is white, but it's still there.

    You have a few options:

    • Make the superview white. This is the easiest but you might not like the way it looks.

    • Make some rounded rect images in your favorite image editor. Set the button type to custom and set your rounded rect images as the button's images.

    • Make a subclass of UIButton and override its drawRect: method.

    • Set the button type to custom and use the button's layer properties (button.layer.backgroundColor, button.layer.borderColor, button.layer.borderWidth, button.layer.cornerRadius) to give the button a rounded rect appearance. You'll have to update button.layer.backgroundColor when the button is touched if you want it to turn blue like a normal one does. (Actually a normal one uses a blue gradient.)

提交回复
热议问题