5

I'm trying to draw a normal rounded rect UIButton, but without the border. Ideally I'd like to be able to change some setting on the UIButton to disable the border.

My problem is that if I change the button type to "custom", I don't get the nice blue selection gradient (which I want to keep), and I have no idea how to draw it manually.

Dave DeLong
  • 242,470
  • 58
  • 448
  • 498

4 Answers4

4

Change the button type to custom. There's a dropdown right below that for "Default", "Highlighted", "Selected", etc. Make a blue gradient, set it as the image for the "Highlighted State Configuration". That should give you the blue gradient when you highlight it. If you want it when it's selected, use the "Selected" configuration.

saramah
  • 168
  • 8
  • Ideally I'd like to just use the built-in blue gradient and keep the rounded-rect shape. – Dave DeLong Mar 31 '10 at 22:00
  • don't think you can — if you want the rounded rect shape, shape the gradient correctly and your custom images like the rounded rect. unfortunately, i think you're going to have to fake it instead of using apple's shininess. – saramah Mar 31 '10 at 23:10
  • You can also try using the `button.layer.cornerRadius` property. – Bill Aug 18 '11 at 13:42
2

I've used a UISegmentedControl with only one segment for this. You can use tintColor you get a nice gradient. The event connections are slightly different but not a big deal.

This answer provides more detail.

Community
  • 1
  • 1
progrmr
  • 75,956
  • 16
  • 112
  • 147
  • I ended up going with this. It doesn't provide the solid white background, and the segmented control still has the border, but it was close enough to what I was trying to do. – Dave DeLong Apr 04 '10 at 20:26
0

try this code,

button.layer.borderWidth = 3;    
button.layer.borderColor = [UIColor whiteColor].CGColor;
Bhavesh Odedra
  • 10,990
  • 12
  • 33
  • 58
0

You can use custom type of UIButton. And set the appropriate image as a background of the UIButton.

MohammedYakub M.
  • 2,893
  • 5
  • 31
  • 42
  • Yes, I know I can do this (I say so in the question). My question is if I can remove the border *without* making it a custom button. – Dave DeLong Apr 01 '10 at 04:28