Get Updates By E-mail 

uiglassbutton

Create Glossy iPhone Buttons Easy Using Interface Builder Or Code Without Images Or Private APIs

  •  
  •  
  •  
  •  
  •  

Last week I posted about a button making tool that utilizes the hidden UIGlassButton class in order to make the sexy colored glass buttons that are common in Apple created applications.

Having to create these buttons was something I was doing at the time, and it surprised me that many others seemed to be doing the same thing.

I was asked by a couple of people if that class was really safe to use, and it was because all you were doing was saving the buttons, and then using them in your own apps — it is perfectly alright since you would just be using png files, but Hwee-Boon has submitted an even easier solution.

The solution is a set of classes that utilize core animation to create the buttons so that no private APIs are used.

What makes this solution easier is that you can just use interface builder and then add in one line of code to set up how you would like the button to look.  No need to export png’s, and load them in.  You can also set them up using code.

The solution along with sample code can be found on Github here:
http://github.com/hboon/GlassButtons

If you’re using interface builder for the buttons it is a pretty simple process:

1. In the interface builder declare the buttons as IBOutlet UIMOButton as opposed to IBOutlet UIButton.
2. Create your buttons with the UIRoundedRect type, and link them to the UIMOButtons you declared making sure the class identity is set to MOGlassButton.
3. When the xib is loaded execute the appropriate method for color and size ie. setupAsGreenButton setupAsSmallGreenButton.

Overall the code is very easy to follow, and looking at the demo project you can easily see exactly how things are done.

You can see in the screenshot below how things can easily be laid out in interface builder and the results including some buttons layed out using code:

Be sure to check out Hwee-Boon’s Posterous for further details (or to just say thanks):
Glass Buttons in iPhone Apps Without Using Image Files

If you like this then please share it with others.  Thanks!


  •  
  •  
  •  
  •  
  •  

Cool Tool For Quickly Making Glossy iOS Buttons

  •  
  •  
  •  
  •  
  •  

Making buttons that match with the iPhone or iPad UI can be a difficult task.

You may have heard that there is an undocumented API in the iPhone sdk known as UIGlassButton which allows you to create buttons, and there’s been some pastie code floating around to save those buttons.

I recently needed to make a few of these buttons, and when I went around to find the code again I stumbled upon something even cooler, someone had hacked up a UIGlassButton button maker with sliders allowing you to tweak the button size, and color, screenshot below:

Overall not the most complicated project, but one that is tremendously useful and since it’s open source you can add in more parameters if you like.  I hope you like it – this is the Github where the files can be downloaded:
ButtonMaker

Just compile in Xcode and run in the simulator, the files will save to the which is shown when you hit the save button even a highlighted version of the button is saved.

Enjoy – I hope you find it as useful as I am.

[Source: Tapadoo]


  •  
  •  
  •  
  •  
  •