Stylish looking glossy buttons with UIButton+Glossy

You’ve all seen the standard, iOS buttons. Although functional, they are, well, plain, to put it mildly.

Perhaps you’ve even tried to make some prettier buttons in photoshop. But if you’re like me, and you have no artistic skills, this can be a challenge. Fortunately, Michael Heyeck has put together a slick little piece of code for generating stylish, glossy buttons.

It’s ridiculously easy to use, and the results look great.

Step 1 – download UIButton+Glossy.h and UIButton+Glossy.m and stick them in your project.

Step 2 – #import “UIButton+Glossy.h” in the view controller that holds your buttons.

Step 3 – style the buttons! This is done by calling the setBackgroundToGlossyRectOfColor:withhBorder:forState method. The color parameter specifies the button’s color. The withBorder parameter specifies whether or not the button should have a border, and the forState parameter is the UIControlState that the style should be applied to.

You can put this code in your view controller’s viewDidLoad method. So, given a UIButton* named button, we can style it like so:

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [button setBackgroundToGlossyRectOfColor:[UIColor colorWithRed:.05 green:.65 blue:.05 alpha:1] withBorder:NO forState:UIControlStateNormal];
}

And with that, you have a stylish looking button!
A little style can go a long way into helping your app stand out from the crowd.

Download the Sample Project

2 Comments

  1. I appreciate, cause I found exactly what I was looking for.

    You’ve ended my four day long hunt! God

    Bless you man. Have a nice day. Bye

    Reply

Leave a Reply to Tilly Cancel reply

Your email address will not be published. Required fields are marked *