Rounded Rect UIButton without the border
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 di开发者_如何转开发sable 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.
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.
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.
You can use custom type of UIButton. And set the appropriate image as a background of the UIButton.
try this code,
button.layer.borderWidth = 3;
button.layer.borderColor = [UIColor whiteColor].CGColor;
精彩评论