1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Code to create a "Glass" button and render it to a png on your desktop.
// Run this from the SIMULATOR and change my username to yours.
// Update: This uses a private iPhone SDK. Do not use this code in your shipping app. Use it merely to generate the PNG file for you to use in a fake button.

Class theClass = NSClassFromString(@"UIGlassButton");
UIButton *theButton = [[[theClass alloc] initWithFrame:CGRectMake(10, 10, 120, 44)] autorelease];
[theButton setValue:[UIColor colorWithHue:0.267 saturation:1.000 brightness:0.667 alpha:1.000] forKey:@"tintColor"];
//[theButton setTitle:@"Accept" forState:UIControlStateNormal];
[self.view addSubview:theButton];

UIGraphicsBeginImageContext(theButton.frame.size);
CGContextRef theContext = UIGraphicsGetCurrentContext();
[theButton.layer renderInContext:theContext];

UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
NSData *theData = UIImagePNGRepresentation(theImage);
[theData writeToFile:@"/Users/schwa/Desktop/test.png" atomically:NO];

UIGraphicsEndImageContext();