Skip to content

Instantly share code, notes, and snippets.

- (void) wiggleEffect
{
CGFloat angle = 5.0 * M_PI / 180;
CGAffineTransform leftWiggle = CGAffineTransformRotate(CGAffineTransformIdentity, -angle);
CGAffineTransform rightWiggle = CGAffineTransformRotate(CGAffineTransformIdentity, angle);
self.image.transform = leftWiggle;
[UIView beginAnimations:@"wiggle" context:(__bridge void *)(self.image)];
- (IBAction)shareInstagramClicked:(id)sender
{
//Instagram URL Scheme
NSURL *instagramURL = [NSURL URLWithString:@"instagram://location?id=1"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
{
NSString *message = @"";
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
- (UIImage*)imageWithImage:(UIImage*)image
scaledToSize:(CGSize)newSize
cropImage:(BOOL)crop {
// Create a graphics image context
CGFloat wFactor = newSize.width / image.size.width;
CGFloat hFactor = newSize.height / image.size.height;
CGFloat maxFactor = MAX(wFactor, hFactor);
if (crop) {
UIGraphicsBeginImageContext(newSize);
@BenBarahona
BenBarahona / FGScrollLayer.h
Created October 25, 2013 21:21
Modified FGScrollLayer class for creating horizontal or vertical scrolls in cocos2d
//
// FGScrollLayer.h
// Fall G
//
// Created by Dai Xuefeng on 23/9/12.
// Copyright 2012 Nofootbird. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "cocos2d.h"
- (NSString *)constructHashTagForAppCopy:(NSString *)appCopy
{
NSRange hashRange = [appCopy rangeOfString:@"#hashtag#" options:NSCaseInsensitiveSearch];
if(hashRange.location != NSNotFound)
{
NSString *hashCopy = [self.channel objectForKey:@"hashtag"];
if(!hashCopy)
{
hashCopy = @"";
}
@BenBarahona
BenBarahona / gist:4049375
Created November 10, 2012 01:14
AppDelegate modifications for Facebook SDK
- (void)applicationDidBecomeActive:(UIApplication *)application
{
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
// FBSample logic
// We need to properly handle activation of the application with regards to SSO
// (e.g., returning from iOS 6.0 authorization dialog or from fast app switching).
[FBSession.activeSession handleDidBecomeActive];
}
@BenBarahona
BenBarahona / gist:3139147
Created July 18, 2012 21:47
Bounce & Shrink View
//BOUNCE ANIMATION
-(void)beginBounceAnimation {
self.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
self.view.alpha = 1.0;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.25];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(bounce1AnimationStopped)];
self.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
[UIView commitAnimations];
@BenBarahona
BenBarahona / gist:1982734
Created March 6, 2012 01:29
MBProgressHUD Mixed
- (IBAction)showWithLabelMixed:(id)sender {
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = @"Connecting";
HUD.minSize = CGSizeMake(135.f, 135.f);
[HUD showWhileExecuting:@selector(myMixedTask) onTarget:self withObject:nil animated:YES];
@BenBarahona
BenBarahona / MbprogressHUD for determinate
Created March 6, 2012 01:02
MBProgress HUD determinate
- (IBAction)showWithLabelDeterminate:(id)sender {
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
// Set determinate mode
HUD.mode = MBProgressHUDModeDeterminate;
HUD.delegate = self;
HUD.labelText = @"Loading";