Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am shauber on github.
  • I am shauber (https://keybase.io/shauber) on keybase.
  • I have a public key whose fingerprint is 93DF 1D45 2686 CE33 3F55 84F0 7743 77E6 5DD0 C01E

To claim this, I am signing this object:

@shauber
shauber / api_keys.rb
Created March 14, 2012 21:05 — forked from cbowns/api_keys.rb
A script for Xcode 4.x to use API keys stored in ~/.api_keys and insert them into your app bundle’s Info.plist (instead of committing them to a repository)
# An API keys script written by Patrick Gibson (@patr1ck) and Christopher Bowns (@cbowns)
# This script sets API keys in your app's Info.plist from an .api_keys file you keep in your home directory (~/.api_keys)
# This allows you to not check API keys into your source control system,
# or for different developers to use different keys without needing to patch their working copies.
# Installation directions:
=begin
1. Create a Run Script build phase in your Xcode project before Compile Sources
2. Copy and paste this whole script in.
3. Create or modify your .api_keys file to hold your API keys
// 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];
NSString *path = [[NSBundle mainBundle] pathForResource:@"Root" ofType:@"plist" inDirectory:@"Settings.bundle"];
NSDictionary *rootDict = [NSDictionary dictionaryWithContentsOfFile:path];
NSArray *prefSpecifiers = [rootDict objectForKey:@"PreferenceSpecifiers"];
NSMutableDictionary *defaults = [NSMutableDictionary dictionaryWithCapacity:[prefSpecifiers count]];
for (NSDictionary *item in prefSpecifiers) {
NSString *key = [item objectForKey:@"Key"];
NSString *value = [item objectForKey:@"DefaultValue"];
[defaults setObject:value forKey:key];
}
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
static const CGFloat KEYBOARD_ANIMATION_DURATION = 0.3;
static const CGFloat MINIMUM_SCROLL_FRACTION = 0.2;
static const CGFloat MAXIMUM_SCROLL_FRACTION = 0.8;
static const CGFloat PORTRAIT_KEYBOARD_HEIGHT = 216;
static const CGFloat LANDSCAPE_KEYBOARD_HEIGHT = 140;
- (void)textFieldDidBeginEditing:(UITextField *)textField {
CGRect textFieldRect = [self.view.window convertRect:textField.bounds fromView:textField];
CGRect viewRect = [self.view.window convertRect:self.view.bounds fromView:self.view];