Skip to content

Instantly share code, notes, and snippets.

@mpsauce
mpsauce / Getting User Profile Information
Created August 26, 2014 21:39
Class Method to get user profile information from provided API
+ (void)getUserProfiles:(void (^)(NSDictionary *))completionBlock {
NSOperationQueue *backgroundQueue = [[NSOperationQueue alloc] init];
MFUser *currentUser = [MFUser currentUser];
NSString *getUserProfile = [NSString stringWithFormat:@"%@%@", kUSER_PROFILE_API_URL, currentUser.uniqueID];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager GET:getUserProfile
parameters:nil
success:^(NSURLSessionDataTask *task, id responseObject) {
@mpsauce
mpsauce / Constants Class
Created August 26, 2014 21:35
This snippet shows constants added to be reused throughout the project
#import <Foundation/Foundation.h>
#define navBarColor [UIColor colorWithRed: 45/255.0 green: 62/255.0 blue: 81/255.0 alpha: 1]
#define tealColor [UIColor colorWithRed: 0 green: 119.0/255.0 blue: 126.0/255.0 alpha: 1.0]
#define darkTealColor [UIColor colorWithRed: 0 green: 80/255.0 blue: 86/255.0 alpha: 1.0]
#define menuFont [UIFont fontWithName: @"NeutraText-BookSC" size: 22]
#define helvetica [UIFont fontWithName: @"HelveticaNeue-Bold" size: 16]
#define helveticaNotifications [UIFont fontWithName: @"HelveticaNeue" size: 16]
#define helveticaUploadScreen [UIFont fontWithName: @"HelveticaNeue-Bold" size: 18]
@mpsauce
mpsauce / Dynamic Image Preview Views
Created August 26, 2014 21:20
This is a code snippet from a project which required me to make Views to dynamically change in size depending on how many images the user tagged.
NSMutableArray *oneImageLayout = [[NSMutableArray alloc] initWithObjects:
[NSValue valueWithCGRect:CGRectMake(0, 0, 155, 210)], nil];
NSMutableArray *twoImageLayout = [[NSMutableArray alloc] initWithObjects:
[NSValue valueWithCGRect:CGRectMake(0, 0, 155, 104)],
[NSValue valueWithCGRect:CGRectMake(0, 105, 155, 105)], nil];
NSMutableArray *threeImageLayout = [[NSMutableArray alloc] initWithObjects:
[NSValue valueWithCGRect:CGRectMake(0, 0, 155, 104)],
[NSValue valueWithCGRect:CGRectMake(0, 105, 77.5, 105)],
@mpsauce
mpsauce / Gaussian Blur
Created August 26, 2014 21:13
This snippet shows adding a gaussian blur using the Quartz Core Framework
CIImage *headerImage = [[CIImage alloc] initWithImage: self.headerImageView.image];
CIFilter *blurFilter = [CIFilter filterWithName: @"CIGaussianBlur"
keysAndValues: kCIInputImageKey, headerImage, @"inputRadius", @(3.0), nil];
CIImage *outputImage = [blurFilter outputImage];
self.context = [CIContext contextWithOptions: nil];
CGImageRef outImage = [self.context createCGImage:outputImage
fromRect: [outputImage extent]];
self.headerImageView.image = [UIImage imageWithCGImage: outImage];
@mpsauce
mpsauce / User Profile Image
Created August 26, 2014 20:54
This is a snippet showing how a user's profile image can be altered to be a circle with a border. Also has custom border color. Glow effect added to Name, title and location to aid in creating contrast against the background
self.profileImageView.layer.cornerRadius = self.profileImageView.frame.size.width / 2;
self.profileImageView.clipsToBounds = YES;
self.profileImageView.layer.borderWidth = 3.0f;
self.profileImageView.layer.borderColor = [UIColor colorWithRed:0.0
green:80.0/255.0
blue:86.0/255.0
alpha:1.0].CGColor;
self.profileName.layer.shadowColor = [[UIColor whiteColor] CGColor];
self.profileName.layer.shadowRadius = 4.0f;