Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
// 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();
This paste will be private.
From the Design Piracy series on my blog: