Skip to content

Instantly share code, notes, and snippets.

View kyleturner's full-sized avatar

Kyle Turner kyleturner

View GitHub Profile
@kyleturner
kyleturner / adjust-constraints.m
Last active August 29, 2015 14:06
Beam iOS Collection View Constraints Animation Adjustments
- (void)adjustConstraintsAndApplyAnimationsForCell:(NGContactCollectionViewCell *)cell
{
CGFloat imageWidth = 104.0;
CGFloat imageHeight = 104.0;
CGFloat defaultActionImageHeight = (self.editing) ? 18.0 : 27.0;
CGFloat nameLabelXOffset = (self.editing) ? 5.0 : 4.0;
CGFloat nameFontSize = (self.editing) ? 12.0 : 16.0;
BOOL contactHasImage = cell.contact.hasContactImage;
@kyleturner
kyleturner / gist:1492044
Created December 18, 2011 01:21
iOS 5.0 Set Navigation Background w/ 4.0 backwards compatibility
if ([self.navigationController.navigationBar respondsToSelector:@selector( setBackgroundImage:forBarMetrics:)]){
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar.png"] forBarMetrics:UIBarMetricsDefault];
}
@kyleturner
kyleturner / gist:1492145
Created December 18, 2011 02:18
UIView Layer Transition Fade In/Out
CATransition *transition = [CATransition animation];
transition.duration = 1.0f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[imageView.layer addAnimation:transition forKey:nil];
@kyleturner
kyleturner / gist:1495898
Created December 19, 2011 07:30
CALayer Animation Vertical Bounce
CABasicAnimation *bounceAnimation = [CABasicAnimation animationWithKeyPath:@"position.y"];
bounceAnimation.duration = .75;
bounceAnimation.speed = 1.25;
bounceAnimation.fromValue = [NSNumber numberWithInt:0];
bounceAnimation.toValue = [NSNumber numberWithInt:-15];
bounceAnimation.repeatCount = INT_MAX;
bounceAnimation.autoreverses = YES;
bounceAnimation.fillMode = kCAFillModeForwards;
bounceAnimation.removedOnCompletion = NO;
bounceAnimation.additive = YES;
@kyleturner
kyleturner / Table View Image View Fade Animation
Created January 4, 2012 23:38
Animation to fade in table cell images
CATransition *transition = [CATransition animation];
transition.duration = 0.35f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[logoView.layer addAnimation:transition forKey:nil];
@kyleturner
kyleturner / NSDateFormatterFormats.txt
Created January 6, 2012 01:35
NSDateFormatter format values
a: AM/PM
A: 0~86399999 (Millisecond of Day)
c/cc: 1~7 (Day of Week)
ccc: Sun/Mon/Tue/Wed/Thu/Fri/Sat
cccc: Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday
d: 1~31 (0 padded Day of Month)
D: 1~366 (0 padded Day of Year)
@kyleturner
kyleturner / CaptureScreenAsImage
Created January 6, 2012 14:57
Takes a render of the current view's layer on screen and saves it as an image to the photo album
UIGraphicsBeginImageContext(webview.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
git rm $(git ls-files --deleted)
@kyleturner
kyleturner / iOS Font Family Names
Created January 8, 2012 07:26
Grab all font family names within the system
// Get all the fonts on the system
NSArray *familyNames = [UIFont familyNames];
for( NSString *familyName in familyNames ){
printf( "Family: %s \n", [familyName UTF8String] );
NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName];
for( NSString *fontName in fontNames ){
printf( "\tFont: %s \n", [fontName UTF8String] );
}
}
@kyleturner
kyleturner / gist:1577785
Created January 8, 2012 09:03
CABasicAnimation opacity
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
[animation setFromValue:[NSNumber numberWithFloat:1.0]];
[animation setToValue:[NSNumber numberWithFloat:0.0]];
[animation setDuration:0.5f];
[animation setTimingFunction:[CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionLinear]];
[animation setAutoreverses:YES];
[animation setRepeatCount:20000];
[[view layer] addAnimation:animation forKey:@"opacity"];