From 6119f62ae1921fc697d32385d760bd7216d66a2e Mon Sep 17 00:00:00 2001 From: Luke Redpath Date: Sun, 20 Jun 2010 19:17:03 +0100 Subject: [PATCH] Initial import of various categories from my various projects --- Classes/Foundation/NSArray+Indexing.h | 16 + Classes/Foundation/NSArray+Indexing.m | 46 +++ Classes/Foundation/NSData+Base64.h | 33 ++ Classes/Foundation/NSData+Base64.m | 299 +++++++++++++++++++ Classes/Foundation/NSString+FileSize.h | 16 + Classes/Foundation/NSString+FileSize.m | 31 ++ Classes/Foundation/NSString+GHTimeInterval.h | 74 +++++ Classes/Foundation/NSString+GHTimeInterval.m | 72 +++++ Classes/Foundation/NSString+Hashing.h | 13 + Classes/Foundation/NSString+Hashing.m | 30 ++ Classes/Foundation/NSURL+StringFormat.h | 17 ++ Classes/Foundation/NSURL+StringFormat.m | 51 ++++ Classes/UIKit/UIColor+Hex.h | 16 + Classes/UIKit/UIColor+Hex.m | 25 ++ Classes/UIKit/UIImage+Alpha.h | 11 + Classes/UIKit/UIImage+Alpha.m | 127 ++++++++ Classes/UIKit/UIImage+Resize.h | 18 ++ Classes/UIKit/UIImage+Resize.m | 195 ++++++++++++ Classes/UIKit/UIImage+RoundedCorner.h | 9 + Classes/UIKit/UIImage+RoundedCorner.m | 79 +++++ Classes/UIKit/UIImageView+LRAdditions.h | 16 + Classes/UIKit/UIImageView+LRAdditions.m | 21 ++ Classes/UIKit/UIToolbar+LRAdditions.h | 16 + Classes/UIKit/UIToolbar+LRAdditions.m | 26 ++ Classes/UIKit/UIView+Position.h | 27 ++ Classes/UIKit/UIView+Position.m | 85 ++++++ LRToolkit.xcodeproj/project.pbxproj | 120 ++++++++ 27 files changed, 1489 insertions(+) create mode 100644 Classes/Foundation/NSArray+Indexing.h create mode 100644 Classes/Foundation/NSArray+Indexing.m create mode 100644 Classes/Foundation/NSData+Base64.h create mode 100644 Classes/Foundation/NSData+Base64.m create mode 100644 Classes/Foundation/NSString+FileSize.h create mode 100644 Classes/Foundation/NSString+FileSize.m create mode 100644 Classes/Foundation/NSString+GHTimeInterval.h create mode 100644 Classes/Foundation/NSString+GHTimeInterval.m create mode 100644 Classes/Foundation/NSString+Hashing.h create mode 100644 Classes/Foundation/NSString+Hashing.m create mode 100644 Classes/Foundation/NSURL+StringFormat.h create mode 100644 Classes/Foundation/NSURL+StringFormat.m create mode 100644 Classes/UIKit/UIColor+Hex.h create mode 100644 Classes/UIKit/UIColor+Hex.m create mode 100644 Classes/UIKit/UIImage+Alpha.h create mode 100644 Classes/UIKit/UIImage+Alpha.m create mode 100644 Classes/UIKit/UIImage+Resize.h create mode 100644 Classes/UIKit/UIImage+Resize.m create mode 100644 Classes/UIKit/UIImage+RoundedCorner.h create mode 100644 Classes/UIKit/UIImage+RoundedCorner.m create mode 100644 Classes/UIKit/UIImageView+LRAdditions.h create mode 100644 Classes/UIKit/UIImageView+LRAdditions.m create mode 100644 Classes/UIKit/UIToolbar+LRAdditions.h create mode 100644 Classes/UIKit/UIToolbar+LRAdditions.m create mode 100644 Classes/UIKit/UIView+Position.h create mode 100644 Classes/UIKit/UIView+Position.m diff --git a/Classes/Foundation/NSArray+Indexing.h b/Classes/Foundation/NSArray+Indexing.h new file mode 100644 index 0000000..643cd8c --- /dev/null +++ b/Classes/Foundation/NSArray+Indexing.h @@ -0,0 +1,16 @@ +// +// NSArray+Indexing.h +// TellYouGov +// +// Created by James Adam on 16/02/2010. +// Copyright 2010 Lazyatom Limited. All rights reserved. +// + +#import + + +@interface NSArray (Indexing) + +- (NSArray *)indexUsingCollation:(UILocalizedIndexedCollation *)collation withSelector:(SEL)selector; + +@end diff --git a/Classes/Foundation/NSArray+Indexing.m b/Classes/Foundation/NSArray+Indexing.m new file mode 100644 index 0000000..f60b899 --- /dev/null +++ b/Classes/Foundation/NSArray+Indexing.m @@ -0,0 +1,46 @@ +// +// NSArray+Indexing.m +// TellYouGov +// +// Created by James Adam on 16/02/2010. +// Copyright 2010 Lazyatom Limited. All rights reserved. +// + +#import "NSArray+Indexing.h" + + +@implementation NSArray (Indexing) + +- (NSArray *)indexUsingCollation:(UILocalizedIndexedCollation *)collation withSelector:(SEL)selector; +{ + NSMutableArray *indexedCollection; + + NSInteger index, sectionTitlesCount = [[collation sectionTitles] count]; + indexedCollection = [[NSMutableArray alloc] initWithCapacity:sectionTitlesCount]; + + for (index = 0; index < sectionTitlesCount; index++) { + NSMutableArray *array = [[NSMutableArray alloc] init]; + [indexedCollection addObject:array]; + [array release]; + } + + // Segregate the data into the appropriate section + for (id object in self) { + NSInteger sectionNumber = [collation sectionForObject:object collationStringSelector:selector]; + [[indexedCollection objectAtIndex:sectionNumber] addObject:object]; + } + + // Now that all the data's in place, each section array needs to be sorted. + for (index = 0; index < sectionTitlesCount; index++) { + NSMutableArray *arrayForSection = [indexedCollection objectAtIndex:index]; + + NSArray *sortedArray = [collation sortedArrayFromArray:arrayForSection collationStringSelector:selector]; + [indexedCollection replaceObjectAtIndex:index withObject:sortedArray]; + } + NSArray *immutableCollection = [indexedCollection copy]; + [indexedCollection release]; + + return [immutableCollection autorelease]; +} + +@end diff --git a/Classes/Foundation/NSData+Base64.h b/Classes/Foundation/NSData+Base64.h new file mode 100644 index 0000000..eb1ff48 --- /dev/null +++ b/Classes/Foundation/NSData+Base64.h @@ -0,0 +1,33 @@ +// +// NSData+Base64.h +// base64 +// +// Created by Matt Gallagher on 2009/06/03. +// Copyright 2009 Matt Gallagher. All rights reserved. +// +// Permission is given to use this source code file, free of charge, in any +// project, commercial or otherwise, entirely at your risk, with the condition +// that any redistribution (in part or whole) of source code must retain +// this copyright and permission notice. Attribution in compiled projects is +// appreciated but not required. +// + +#import + +void *NewBase64Decode( + const char *inputBuffer, + size_t length, + size_t *outputLength); + +char *NewBase64Encode( + const void *inputBuffer, + size_t length, + bool separateLines, + size_t *outputLength); + +@interface NSData (Base64) + ++ (NSData *)dataFromBase64String:(NSString *)aString; +- (NSString *)base64EncodedString; + +@end diff --git a/Classes/Foundation/NSData+Base64.m b/Classes/Foundation/NSData+Base64.m new file mode 100644 index 0000000..3f50580 --- /dev/null +++ b/Classes/Foundation/NSData+Base64.m @@ -0,0 +1,299 @@ +// +// NSData+Base64.m +// base64 +// +// Created by Matt Gallagher on 2009/06/03. +// Copyright 2009 Matt Gallagher. All rights reserved. +// +// Permission is given to use this source code file, free of charge, in any +// project, commercial or otherwise, entirely at your risk, with the condition +// that any redistribution (in part or whole) of source code must retain +// this copyright and permission notice. Attribution in compiled projects is +// appreciated but not required. +// + +#import "NSData+Base64.h" + +// +// Mapping from 6 bit pattern to ASCII character. +// +static unsigned char base64EncodeLookup[65] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +// +// Definition for "masked-out" areas of the base64DecodeLookup mapping +// +#define xx 65 + +// +// Mapping from ASCII character to 6 bit pattern. +// +static unsigned char base64DecodeLookup[256] = +{ + xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, + xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, + xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 62, xx, xx, xx, 63, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, xx, xx, xx, xx, xx, xx, + xx, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, xx, xx, xx, xx, xx, + xx, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, xx, xx, xx, xx, xx, + xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, + xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, + xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, + xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, + xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, + xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, + xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, + xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, +}; + +// +// Fundamental sizes of the binary and base64 encode/decode units in bytes +// +#define BINARY_UNIT_SIZE 3 +#define BASE64_UNIT_SIZE 4 + +// +// NewBase64Decode +// +// Decodes the base64 ASCII string in the inputBuffer to a newly malloced +// output buffer. +// +// inputBuffer - the source ASCII string for the decode +// length - the length of the string or -1 (to specify strlen should be used) +// outputLength - if not-NULL, on output will contain the decoded length +// +// returns the decoded buffer. Must be free'd by caller. Length is given by +// outputLength. +// +void *NewBase64Decode( + const char *inputBuffer, + size_t length, + size_t *outputLength) +{ + if (length == -1) + { + length = strlen(inputBuffer); + } + + size_t outputBufferSize = + ((length+BASE64_UNIT_SIZE-1) / BASE64_UNIT_SIZE) * BINARY_UNIT_SIZE; + unsigned char *outputBuffer = (unsigned char *)malloc(outputBufferSize); + + size_t i = 0; + size_t j = 0; + while (i < length) + { + // + // Accumulate 4 valid characters (ignore everything else) + // + unsigned char accumulated[BASE64_UNIT_SIZE]; + size_t accumulateIndex = 0; + while (i < length) + { + unsigned char decode = base64DecodeLookup[inputBuffer[i++]]; + if (decode != xx) + { + accumulated[accumulateIndex] = decode; + accumulateIndex++; + + if (accumulateIndex == BASE64_UNIT_SIZE) + { + break; + } + } + } + + // + // Store the 6 bits from each of the 4 characters as 3 bytes + // + outputBuffer[j] = (accumulated[0] << 2) | (accumulated[1] >> 4); + outputBuffer[j + 1] = (accumulated[1] << 4) | (accumulated[2] >> 2); + outputBuffer[j + 2] = (accumulated[2] << 6) | accumulated[3]; + j += accumulateIndex - 1; + } + + if (outputLength) + { + *outputLength = j; + } + return outputBuffer; +} + +// +// NewBase64Decode +// +// Encodes the arbitrary data in the inputBuffer as base64 into a newly malloced +// output buffer. +// +// inputBuffer - the source data for the encode +// length - the length of the input in bytes +// separateLines - if zero, no CR/LF characters will be added. Otherwise +// a CR/LF pair will be added every 64 encoded chars. +// outputLength - if not-NULL, on output will contain the encoded length +// (not including terminating 0 char) +// +// returns the encoded buffer. Must be free'd by caller. Length is given by +// outputLength. +// +char *NewBase64Encode( + const void *buffer, + size_t length, + bool separateLines, + size_t *outputLength) +{ + const unsigned char *inputBuffer = (const unsigned char *)buffer; + + #define MAX_NUM_PADDING_CHARS 2 + #define OUTPUT_LINE_LENGTH 64 + #define INPUT_LINE_LENGTH ((OUTPUT_LINE_LENGTH / BASE64_UNIT_SIZE) * BINARY_UNIT_SIZE) + #define CR_LF_SIZE 2 + + // + // Byte accurate calculation of final buffer size + // + size_t outputBufferSize = + ((length / BINARY_UNIT_SIZE) + + ((length % BINARY_UNIT_SIZE) ? 1 : 0)) + * BASE64_UNIT_SIZE; + if (separateLines) + { + outputBufferSize += + (outputBufferSize / OUTPUT_LINE_LENGTH) * CR_LF_SIZE; + } + + // + // Include space for a terminating zero + // + outputBufferSize += 1; + + // + // Allocate the output buffer + // + char *outputBuffer = (char *)malloc(outputBufferSize); + if (!outputBuffer) + { + return NULL; + } + + size_t i = 0; + size_t j = 0; + const size_t lineLength = separateLines ? INPUT_LINE_LENGTH : length; + size_t lineEnd = lineLength; + + while (true) + { + if (lineEnd > length) + { + lineEnd = length; + } + + for (; i + BINARY_UNIT_SIZE - 1 < lineEnd; i += BINARY_UNIT_SIZE) + { + // + // Inner loop: turn 48 bytes into 64 base64 characters + // + outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2]; + outputBuffer[j++] = base64EncodeLookup[((inputBuffer[i] & 0x03) << 4) + | ((inputBuffer[i + 1] & 0xF0) >> 4)]; + outputBuffer[j++] = base64EncodeLookup[((inputBuffer[i + 1] & 0x0F) << 2) + | ((inputBuffer[i + 2] & 0xC0) >> 6)]; + outputBuffer[j++] = base64EncodeLookup[inputBuffer[i + 2] & 0x3F]; + } + + if (lineEnd == length) + { + break; + } + + // + // Add the newline + // + outputBuffer[j++] = '\r'; + outputBuffer[j++] = '\n'; + lineEnd += lineLength; + } + + if (i + 1 < length) + { + // + // Handle the single '=' case + // + outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2]; + outputBuffer[j++] = base64EncodeLookup[((inputBuffer[i] & 0x03) << 4) + | ((inputBuffer[i + 1] & 0xF0) >> 4)]; + outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i + 1] & 0x0F) << 2]; + outputBuffer[j++] = '='; + } + else if (i < length) + { + // + // Handle the double '=' case + // + outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2]; + outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0x03) << 4]; + outputBuffer[j++] = '='; + outputBuffer[j++] = '='; + } + outputBuffer[j] = 0; + + // + // Set the output length and return the buffer + // + if (outputLength) + { + *outputLength = j; + } + return outputBuffer; +} + +@implementation NSData (Base64) + +// +// dataFromBase64String: +// +// Creates an NSData object containing the base64 decoded representation of +// the base64 string 'aString' +// +// Parameters: +// aString - the base64 string to decode +// +// returns the autoreleased NSData representation of the base64 string +// ++ (NSData *)dataFromBase64String:(NSString *)aString +{ + NSData *data = [aString dataUsingEncoding:NSASCIIStringEncoding]; + size_t outputLength; + void *outputBuffer = NewBase64Decode([data bytes], [data length], &outputLength); + NSData *result = [NSData dataWithBytes:outputBuffer length:outputLength]; + free(outputBuffer); + return result; +} + +// +// base64EncodedString +// +// Creates an NSString object that contains the base 64 encoding of the +// receiver's data. Lines are broken at 64 characters long. +// +// returns an autoreleased NSString being the base 64 representation of the +// receiver. +// +- (NSString *)base64EncodedString +{ + size_t outputLength; + char *outputBuffer = + NewBase64Encode([self bytes], [self length], true, &outputLength); + + NSString *result = + [[[NSString alloc] + initWithBytes:outputBuffer + length:outputLength + encoding:NSASCIIStringEncoding] + autorelease]; + free(outputBuffer); + return result; +} + +@end diff --git a/Classes/Foundation/NSString+FileSize.h b/Classes/Foundation/NSString+FileSize.h new file mode 100644 index 0000000..656c6cb --- /dev/null +++ b/Classes/Foundation/NSString+FileSize.h @@ -0,0 +1,16 @@ +// +// NSString+FileSize.h +// Spark +// +// Created by Luke Redpath on 22/05/2010. +// Copyright 2010 LJR Software Limited. All rights reserved. +// + +#import + + +@interface NSString (FileSize) + ++ (NSString *)fileSizeStringFromByes:(int)bytes; + +@end diff --git a/Classes/Foundation/NSString+FileSize.m b/Classes/Foundation/NSString+FileSize.m new file mode 100644 index 0000000..04e95c6 --- /dev/null +++ b/Classes/Foundation/NSString+FileSize.m @@ -0,0 +1,31 @@ +// +// NSString+FileSize.m +// Spark +// +// Created by Luke Redpath on 22/05/2010. +// Copyright 2010 LJR Software Limited. All rights reserved. +// + +#import "NSString+FileSize.h" + +@implementation NSString (FileSize) + ++ (NSString *)fileSizeStringFromByes:(int)bytes; +{ + float floatSize = (float)bytes; + + if (bytes<1023) + return([NSString stringWithFormat:@"%d bytes",bytes]); + floatSize = floatSize / 1024; + if (floatSize<1023) + return([NSString stringWithFormat:@"%1.1f KB",floatSize]); + floatSize = floatSize / 1024; + if (floatSize<1023) + return([NSString stringWithFormat:@"%1.1f MB",floatSize]); + floatSize = floatSize / 1024; + + return([NSString stringWithFormat:@"%1.1f GB",floatSize]); + +} + +@end diff --git a/Classes/Foundation/NSString+GHTimeInterval.h b/Classes/Foundation/NSString+GHTimeInterval.h new file mode 100644 index 0000000..ae28abd --- /dev/null +++ b/Classes/Foundation/NSString+GHTimeInterval.h @@ -0,0 +1,74 @@ +// +// GHNSString+TimeInterval.h +// +// Created by Gabe on 6/6/08. +// Copyright 2008 Gabriel Handford +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + + +@interface NSString (GHTimeInterval) + +/*! + @method gh_stringForTimeInterval + @abstract Get time ago in words + @param interval + @param includeSeconds If YES, will say 'less than N seconds', otherwise will show 'less than a minute' + @result Time ago in words + + For localized values see the localization keys below. + This method calls gh_localizedStringForTimeInterval with nil tableName and [NSBundle mainBundle] bundle. + */ ++ (NSString *)gh_stringForTimeInterval:(NSTimeInterval)interval includeSeconds:(BOOL)includeSeconds; + +/*! + Localized string for time interval. (Time ago in words.) + @method gh_localizedStringForTimeInterval + @abstract Get time ago in words + @param interval + @param includeSeconds If YES, will say 'less than N seconds', otherwise will show 'less than a minute' + @param tableName Table name for localized string + @param bundle Bundle for localized string + @result Time ago in words + + These are the localized defaults, that you can override: + + LessThanAMinute = "less than a minute"; + LessThanXSeconds = "less than %d seconds"; + HalfMinute = "half a minute"; + 1Minute = "1 minute"; + XMinutes = "%.0f minutes"; + About1Hour = "about 1 hour"; + AboutXHours = "about %.0f hours"; + 1Day = "1 day"; + XDays = "%.0f days"; + About1Month = "about 1 month"; + XMonths = "%.0f months"; + About1Year = "about 1 year"; + OverXYears = "over %.0f years"; + */ ++ (NSString *)gh_localizedStringForTimeInterval:(NSTimeInterval)interval includeSeconds:(BOOL)includeSeconds tableName:(NSString *)tableName bundle:(NSBundle *)bundle; + ++ (NSString *)gh_stringForTimeSinceDate:(NSDate *)date includeSeconds:(BOOL)includeSeconds; + +@end \ No newline at end of file diff --git a/Classes/Foundation/NSString+GHTimeInterval.m b/Classes/Foundation/NSString+GHTimeInterval.m new file mode 100644 index 0000000..0abb609 --- /dev/null +++ b/Classes/Foundation/NSString+GHTimeInterval.m @@ -0,0 +1,72 @@ +// +// GHNSString+TimeInterval.m +// +// Created by Gabe on 6/6/08. +// Copyright 2008 Gabriel Handford +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import "NSString+GHTimeInterval.h" + +#import + +@implementation NSString (GHTimeInterval) + +#define GHIntervalLocalize(key, defaultValue) NSLocalizedStringWithDefaultValue(key, tableName, bundle, defaultValue, nil) + ++ (NSString *)gh_stringForTimeInterval:(NSTimeInterval)interval includeSeconds:(BOOL)includeSeconds { + return [self gh_localizedStringForTimeInterval:interval includeSeconds:includeSeconds tableName:nil bundle:[NSBundle mainBundle]]; +} + ++ (NSString *)gh_localizedStringForTimeInterval:(NSTimeInterval)interval includeSeconds:(BOOL)includeSeconds tableName:(NSString *)tableName bundle:(NSBundle *)bundle { + NSTimeInterval intervalInSeconds = fabs(interval); + double intervalInMinutes = round(intervalInSeconds/60.0); + + if (intervalInMinutes >= 0 && intervalInMinutes <= 1) { + if (!includeSeconds) return intervalInMinutes <= 0 ? GHIntervalLocalize(@"LessThanAMinute", @"less than a minute") : GHIntervalLocalize(@"1Minute", @"1 minute"); + if (intervalInSeconds >= 0 && intervalInSeconds < 5) return [NSString stringWithFormat:GHIntervalLocalize(@"LessThanXSeconds", @"less than %d seconds"), 5]; + else if (intervalInSeconds >= 5 && intervalInSeconds < 10) return [NSString stringWithFormat:GHIntervalLocalize(@"LessThanXSeconds", @"less than %d seconds"), 10]; + else if (intervalInSeconds >= 10 && intervalInSeconds < 20) return [NSString stringWithFormat:GHIntervalLocalize(@"LessThanXSeconds", @"less than %d seconds"), 20]; + else if (intervalInSeconds >= 20 && intervalInSeconds < 40) return GHIntervalLocalize(@"HalfMinute", @"half a minute"); + else if (intervalInSeconds >= 40 && intervalInSeconds < 60) return GHIntervalLocalize(@"LessThanAMinute", @"less than a minute"); + else return GHIntervalLocalize(@"1Minute", @"1 minute"); + } + else if (intervalInMinutes >= 2 && intervalInMinutes <= 44) return [NSString stringWithFormat:GHIntervalLocalize(@"XMinutes", @"%.0f minutes"), intervalInMinutes]; + else if (intervalInMinutes >= 45 && intervalInMinutes <= 89) return GHIntervalLocalize(@"About1Hour", @"about 1 hour"); + else if (intervalInMinutes >= 90 && intervalInMinutes <= 1439) return [NSString stringWithFormat:GHIntervalLocalize(@"AboutXHours", @"about %.0f hours"), round(intervalInMinutes/60.0)]; + else if (intervalInMinutes >= 1440 && intervalInMinutes <= 2879) return GHIntervalLocalize(@"1Day", @"1 day"); + else if (intervalInMinutes >= 2880 && intervalInMinutes <= 43199) return [NSString stringWithFormat:GHIntervalLocalize(@"XDays", @"%.0f days"), round(intervalInMinutes/1440.0)]; + else if (intervalInMinutes >= 43200 && intervalInMinutes <= 86399) return GHIntervalLocalize(@"About1Month", @"about 1 month"); + else if (intervalInMinutes >= 86400 && intervalInMinutes <= 525599) return [NSString stringWithFormat:GHIntervalLocalize(@"XMonths", @"%.0f months"), round(intervalInMinutes/43200.0)]; + else if (intervalInMinutes >= 525600 && intervalInMinutes <= 1051199) return GHIntervalLocalize(@"About1Year", @"about 1 year"); + else + return [NSString stringWithFormat:GHIntervalLocalize(@"OverXYears", @"over %.0f years"), round(intervalInMinutes/525600.0)]; +} + ++ (NSString *)gh_stringForTimeSinceDate:(NSDate *)date includeSeconds:(BOOL)includeSeconds; +{ + NSTimeInterval timeInterval = [[NSDate date] timeIntervalSinceDate:date]; + return [self gh_stringForTimeInterval:timeInterval includeSeconds:includeSeconds]; +} + +@end \ No newline at end of file diff --git a/Classes/Foundation/NSString+Hashing.h b/Classes/Foundation/NSString+Hashing.h new file mode 100644 index 0000000..1d3ff89 --- /dev/null +++ b/Classes/Foundation/NSString+Hashing.h @@ -0,0 +1,13 @@ +// +// NSString+Hashing.h +// SqueezeAPI +// +// Created by Luke Redpath on 07/05/2009. +// + +#import + + +@interface NSString (Hashing) +- (NSString *)MD5Hash; +@end diff --git a/Classes/Foundation/NSString+Hashing.m b/Classes/Foundation/NSString+Hashing.m new file mode 100644 index 0000000..98c44f6 --- /dev/null +++ b/Classes/Foundation/NSString+Hashing.m @@ -0,0 +1,30 @@ +// +// NSString+Hashing.m +// SqueezeAPI +// +// Created by Luke Redpath on 07/05/2009. +// + +#import "NSString+Hashing.h" +#import + +NSString* md5( NSString *str ) +{ + const char *cStr = [str UTF8String]; + unsigned char result[CC_MD5_DIGEST_LENGTH]; + CC_MD5( cStr, strlen(cStr), result ); + return [NSString stringWithFormat: + @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", + result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7], + result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15] + ]; +} + +@implementation NSString (Hashing) + +- (NSString *)MD5Hash; +{ + return md5(self); +} + +@end diff --git a/Classes/Foundation/NSURL+StringFormat.h b/Classes/Foundation/NSURL+StringFormat.h new file mode 100644 index 0000000..ed2c255 --- /dev/null +++ b/Classes/Foundation/NSURL+StringFormat.h @@ -0,0 +1,17 @@ +// +// NSURL+StringFormat.h +// Camppad +// +// Created by Luke Redpath on 01/05/2010. +// Copyright 2010 LJR Software Limited. All rights reserved. +// + +#import + + +@interface NSURL (StringFormat) +- (id)initWithFormat:(NSString *)formatString, ...; +- (id)initWithFormat:(NSString *)formatString arguments:(va_list)args; ++ (id)URLWithFormat:(NSString *)formatString, ...; ++ (id)URLWithFormat:(NSString *)formatString relativeToURL:(NSURL *)baseURL, ...; +@end diff --git a/Classes/Foundation/NSURL+StringFormat.m b/Classes/Foundation/NSURL+StringFormat.m new file mode 100644 index 0000000..f09e53b --- /dev/null +++ b/Classes/Foundation/NSURL+StringFormat.m @@ -0,0 +1,51 @@ +// +// NSURL+StringFormat.m +// Camppad +// +// Created by Luke Redpath on 01/05/2010. +// Copyright 2010 LJR Software Limited. All rights reserved. +// + +#import "NSURL+StringFormat.h" + + +@implementation NSURL (StringFormat) + +- (id)initWithFormat:(NSString *)formatString, ...; +{ + va_list args; + va_start(args, formatString); + self = [self initWithFormat:formatString arguments:args]; + va_end(args); + return self; +} + +- (id)initWithFormat:(NSString *)formatString arguments:(va_list)args; +{ + NSString *urlString = [[NSString alloc] initWithFormat:formatString arguments:args]; + self = [self initWithString:urlString]; + [urlString release]; + return self; +} + ++ (id)URLWithFormat:(NSString *)formatString, ...; +{ + va_list args; + va_start(args, formatString); + NSURL *url = [[self alloc] initWithFormat:formatString arguments:args]; + va_end(args); + return [url autorelease]; +} + ++ (id)URLWithFormat:(NSString *)formatString relativeToURL:(NSURL *)baseURL, ...; +{ + va_list args; + va_start(args, baseURL); + NSString *path = [[NSString alloc] initWithFormat:formatString arguments:args]; + NSURL *url = [self URLWithString:path relativeToURL:baseURL]; + [path release]; + va_end(args); + return url; +} + +@end diff --git a/Classes/UIKit/UIColor+Hex.h b/Classes/UIKit/UIColor+Hex.h new file mode 100644 index 0000000..5409e19 --- /dev/null +++ b/Classes/UIKit/UIColor+Hex.h @@ -0,0 +1,16 @@ +// +// UIColor+Hex.h +// TellYouGov +// +// Created by Luke Redpath on 27/04/2010. +// Copyright 2010 LJR Software Limited. All rights reserved. +// + +#import + + +@interface UIColor (Hex) + ++ (UIColor *)colorWithHexValue:(int)hexValue; + +@end diff --git a/Classes/UIKit/UIColor+Hex.m b/Classes/UIKit/UIColor+Hex.m new file mode 100644 index 0000000..3a903bf --- /dev/null +++ b/Classes/UIKit/UIColor+Hex.m @@ -0,0 +1,25 @@ +// +// UIColor+Hex.m +// TellYouGov +// +// Created by Luke Redpath on 27/04/2010. +// Copyright 2010 LJR Software Limited. All rights reserved. +// + +#import "UIColor+Hex.h" + + +@implementation UIColor (Hex) + +/** + * courtesy of http://pessoal.org/blog/2008/11/27/creating-uicolor-objects-from-hex-values/ + */ + ++ (UIColor *)colorWithHexValue:(int)rgbValue; +{ + return [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 + green:((float)((rgbValue & 0xFF00) >> 8))/255.0 + blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]; +} + +@end diff --git a/Classes/UIKit/UIImage+Alpha.h b/Classes/UIKit/UIImage+Alpha.h new file mode 100644 index 0000000..370d978 --- /dev/null +++ b/Classes/UIKit/UIImage+Alpha.h @@ -0,0 +1,11 @@ +// UIImage+Alpha.h +// Created by Trevor Harmon on 9/20/09. +// Free for personal or commercial use, with or without modification. +// No warranty is expressed or implied. + +// Helper methods for adding an alpha layer to an image +@interface UIImage (Alpha) +- (BOOL)hasAlpha; +- (UIImage *)imageWithAlpha; +- (UIImage *)transparentBorderImage:(NSUInteger)borderSize; +@end diff --git a/Classes/UIKit/UIImage+Alpha.m b/Classes/UIKit/UIImage+Alpha.m new file mode 100644 index 0000000..d731062 --- /dev/null +++ b/Classes/UIKit/UIImage+Alpha.m @@ -0,0 +1,127 @@ +// UIImage+Alpha.m +// Created by Trevor Harmon on 9/20/09. +// Free for personal or commercial use, with or without modification. +// No warranty is expressed or implied. + +#import "UIImage+Alpha.h" + +// Private helper methods +@interface UIImage () +- (CGImageRef)newBorderMask:(NSUInteger)borderSize size:(CGSize)size; +@end + +@implementation UIImage (Alpha) + +// Returns true if the image has an alpha layer +- (BOOL)hasAlpha { + CGImageAlphaInfo alpha = CGImageGetAlphaInfo(self.CGImage); + return (alpha == kCGImageAlphaFirst || + alpha == kCGImageAlphaLast || + alpha == kCGImageAlphaPremultipliedFirst || + alpha == kCGImageAlphaPremultipliedLast); +} + +// Returns a copy of the given image, adding an alpha channel if it doesn't already have one +- (UIImage *)imageWithAlpha { + if ([self hasAlpha]) { + return self; + } + + CGImageRef imageRef = self.CGImage; + size_t width = CGImageGetWidth(imageRef); + size_t height = CGImageGetHeight(imageRef); + + // The bitsPerComponent and bitmapInfo values are hard-coded to prevent an "unsupported parameter combination" error + CGContextRef offscreenContext = CGBitmapContextCreate(NULL, + width, + height, + 8, + 0, + CGImageGetColorSpace(imageRef), + kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedFirst); + + // Draw the image into the context and retrieve the new image, which will now have an alpha layer + CGContextDrawImage(offscreenContext, CGRectMake(0, 0, width, height), imageRef); + CGImageRef imageRefWithAlpha = CGBitmapContextCreateImage(offscreenContext); + UIImage *imageWithAlpha = [UIImage imageWithCGImage:imageRefWithAlpha]; + + // Clean up + CGContextRelease(offscreenContext); + CGImageRelease(imageRefWithAlpha); + + return imageWithAlpha; +} + +// Returns a copy of the image with a transparent border of the given size added around its edges. +// If the image has no alpha layer, one will be added to it. +- (UIImage *)transparentBorderImage:(NSUInteger)borderSize { + // If the image does not have an alpha layer, add one + UIImage *image = [self imageWithAlpha]; + + CGRect newRect = CGRectMake(0, 0, image.size.width + borderSize * 2, image.size.height + borderSize * 2); + + // Build a context that's the same dimensions as the new size + CGContextRef bitmap = CGBitmapContextCreate(NULL, + newRect.size.width, + newRect.size.height, + CGImageGetBitsPerComponent(self.CGImage), + 0, + CGImageGetColorSpace(self.CGImage), + CGImageGetBitmapInfo(self.CGImage)); + + // Draw the image in the center of the context, leaving a gap around the edges + CGRect imageLocation = CGRectMake(borderSize, borderSize, image.size.width, image.size.height); + CGContextDrawImage(bitmap, imageLocation, self.CGImage); + CGImageRef borderImageRef = CGBitmapContextCreateImage(bitmap); + + // Create a mask to make the border transparent, and combine it with the image + CGImageRef maskImageRef = [self newBorderMask:borderSize size:newRect.size]; + CGImageRef transparentBorderImageRef = CGImageCreateWithMask(borderImageRef, maskImageRef); + UIImage *transparentBorderImage = [UIImage imageWithCGImage:transparentBorderImageRef]; + + // Clean up + CGContextRelease(bitmap); + CGImageRelease(borderImageRef); + CGImageRelease(maskImageRef); + CGImageRelease(transparentBorderImageRef); + + return transparentBorderImage; +} + +#pragma mark - +#pragma mark Private helper methods + +// Creates a mask that makes the outer edges transparent and everything else opaque +// The size must include the entire mask (opaque part + transparent border) +// The caller is responsible for releasing the returned reference by calling CGImageRelease +- (CGImageRef)newBorderMask:(NSUInteger)borderSize size:(CGSize)size { + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray(); + + // Build a context that's the same dimensions as the new size + CGContextRef maskContext = CGBitmapContextCreate(NULL, + size.width, + size.height, + 8, // 8-bit grayscale + 0, + colorSpace, + kCGBitmapByteOrderDefault | kCGImageAlphaNone); + + // Start with a mask that's entirely transparent + CGContextSetFillColorWithColor(maskContext, [UIColor blackColor].CGColor); + CGContextFillRect(maskContext, CGRectMake(0, 0, size.width, size.height)); + + // Make the inner part (within the border) opaque + CGContextSetFillColorWithColor(maskContext, [UIColor whiteColor].CGColor); + CGContextFillRect(maskContext, CGRectMake(borderSize, borderSize, size.width - borderSize * 2, size.height - borderSize * 2)); + + // Get an image of the context + CGImageRef maskImageRef = CGBitmapContextCreateImage(maskContext); + + // Clean up + CGContextRelease(maskContext); + CGColorSpaceRelease(colorSpace); + + return maskImageRef; +} + +@end diff --git a/Classes/UIKit/UIImage+Resize.h b/Classes/UIKit/UIImage+Resize.h new file mode 100644 index 0000000..f143381 --- /dev/null +++ b/Classes/UIKit/UIImage+Resize.h @@ -0,0 +1,18 @@ +// UIImage+Resize.h +// Created by Trevor Harmon on 8/5/09. +// Free for personal or commercial use, with or without modification. +// No warranty is expressed or implied. + +// Extends the UIImage class to support resizing/cropping +@interface UIImage (Resize) +- (UIImage *)croppedImage:(CGRect)bounds; +- (UIImage *)thumbnailImage:(NSInteger)thumbnailSize + transparentBorder:(NSUInteger)borderSize + cornerRadius:(NSUInteger)cornerRadius + interpolationQuality:(CGInterpolationQuality)quality; +- (UIImage *)resizedImage:(CGSize)newSize + interpolationQuality:(CGInterpolationQuality)quality; +- (UIImage *)resizedImageWithContentMode:(UIViewContentMode)contentMode + bounds:(CGSize)bounds + interpolationQuality:(CGInterpolationQuality)quality; +@end diff --git a/Classes/UIKit/UIImage+Resize.m b/Classes/UIKit/UIImage+Resize.m new file mode 100644 index 0000000..71096d2 --- /dev/null +++ b/Classes/UIKit/UIImage+Resize.m @@ -0,0 +1,195 @@ +// UIImage+Resize.m +// Created by Trevor Harmon on 8/5/09. +// Free for personal or commercial use, with or without modification. +// No warranty is expressed or implied. + +#import "UIImage+Resize.h" +#import "UIImage+RoundedCorner.h" +#import "UIImage+Alpha.h" + +// Private helper methods +@interface UIImage () +- (UIImage *)resizedImage:(CGSize)newSize + transform:(CGAffineTransform)transform + drawTransposed:(BOOL)transpose + interpolationQuality:(CGInterpolationQuality)quality; +- (CGAffineTransform)transformForOrientation:(CGSize)newSize; +@end + +@implementation UIImage (Resize) + +// Returns a copy of this image that is cropped to the given bounds. +// The bounds will be adjusted using CGRectIntegral. +// This method ignores the image's imageOrientation setting. +- (UIImage *)croppedImage:(CGRect)bounds { + CGImageRef imageRef = CGImageCreateWithImageInRect([self CGImage], bounds); + UIImage *croppedImage = [UIImage imageWithCGImage:imageRef]; + CGImageRelease(imageRef); + return croppedImage; +} + +// Returns a copy of this image that is squared to the thumbnail size. +// If transparentBorder is non-zero, a transparent border of the given size will be added around the edges of the thumbnail. (Adding a transparent border of at least one pixel in size has the side-effect of antialiasing the edges of the image when rotating it using Core Animation.) +- (UIImage *)thumbnailImage:(NSInteger)thumbnailSize + transparentBorder:(NSUInteger)borderSize + cornerRadius:(NSUInteger)cornerRadius + interpolationQuality:(CGInterpolationQuality)quality { + UIImage *resizedImage = [self resizedImageWithContentMode:UIViewContentModeScaleAspectFill + bounds:CGSizeMake(thumbnailSize, thumbnailSize) + interpolationQuality:quality]; + + // Crop out any part of the image that's larger than the thumbnail size + // The cropped rect must be centered on the resized image + // Round the origin points so that the size isn't altered when CGRectIntegral is later invoked + CGRect cropRect = CGRectMake(round((resizedImage.size.width - thumbnailSize) / 2), + round((resizedImage.size.height - thumbnailSize) / 2), + thumbnailSize, + thumbnailSize); + UIImage *croppedImage = [resizedImage croppedImage:cropRect]; + + UIImage *transparentBorderImage = borderSize ? [croppedImage transparentBorderImage:borderSize] : croppedImage; + + return [transparentBorderImage roundedCornerImage:cornerRadius borderSize:borderSize]; +} + +// Returns a rescaled copy of the image, taking into account its orientation +// The image will be scaled disproportionately if necessary to fit the bounds specified by the parameter +- (UIImage *)resizedImage:(CGSize)newSize interpolationQuality:(CGInterpolationQuality)quality { + BOOL drawTransposed; + + switch (self.imageOrientation) { + case UIImageOrientationLeft: + case UIImageOrientationLeftMirrored: + case UIImageOrientationRight: + case UIImageOrientationRightMirrored: + drawTransposed = YES; + break; + + default: + drawTransposed = NO; + } + + return [self resizedImage:newSize + transform:[self transformForOrientation:newSize] + drawTransposed:drawTransposed + interpolationQuality:quality]; +} + +// Resizes the image according to the given content mode, taking into account the image's orientation +- (UIImage *)resizedImageWithContentMode:(UIViewContentMode)contentMode + bounds:(CGSize)bounds + interpolationQuality:(CGInterpolationQuality)quality { + CGFloat horizontalRatio = bounds.width / self.size.width; + CGFloat verticalRatio = bounds.height / self.size.height; + CGFloat ratio; + + switch (contentMode) { + case UIViewContentModeScaleAspectFill: + ratio = MAX(horizontalRatio, verticalRatio); + break; + + case UIViewContentModeScaleAspectFit: + ratio = MIN(horizontalRatio, verticalRatio); + break; + + default: + [NSException raise:NSInvalidArgumentException format:@"Unsupported content mode: %d", contentMode]; + } + + CGSize newSize = CGSizeMake(self.size.width * ratio, self.size.height * ratio); + + return [self resizedImage:newSize interpolationQuality:quality]; +} + +#pragma mark - +#pragma mark Private helper methods + +// Returns a copy of the image that has been transformed using the given affine transform and scaled to the new size +// The new image's orientation will be UIImageOrientationUp, regardless of the current image's orientation +// If the new size is not integral, it will be rounded up +- (UIImage *)resizedImage:(CGSize)newSize + transform:(CGAffineTransform)transform + drawTransposed:(BOOL)transpose + interpolationQuality:(CGInterpolationQuality)quality { + CGRect newRect = CGRectIntegral(CGRectMake(0, 0, newSize.width, newSize.height)); + CGRect transposedRect = CGRectMake(0, 0, newRect.size.height, newRect.size.width); + CGImageRef imageRef = self.CGImage; + + // fix for non-supported bits/channel combinations + CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); + if (CGImageGetAlphaInfo(imageRef) == kCGImageAlphaNone) { + bitmapInfo &= ~kCGBitmapAlphaInfoMask; + bitmapInfo |= kCGImageAlphaNoneSkipLast; + } + + // Build a context that's the same dimensions as the new size + CGContextRef bitmap = CGBitmapContextCreate(NULL, + newRect.size.width, + newRect.size.height, + CGImageGetBitsPerComponent(imageRef), + 0, + CGImageGetColorSpace(imageRef), + bitmapInfo); + + // Rotate and/or flip the image if required by its orientation + CGContextConcatCTM(bitmap, transform); + + // Set the quality level to use when rescaling + CGContextSetInterpolationQuality(bitmap, quality); + + // Draw into the context; this scales the image + CGContextDrawImage(bitmap, transpose ? transposedRect : newRect, imageRef); + + // Get the resized image from the context and a UIImage + CGImageRef newImageRef = CGBitmapContextCreateImage(bitmap); + UIImage *newImage = [UIImage imageWithCGImage:newImageRef]; + + // Clean up + CGContextRelease(bitmap); + CGImageRelease(newImageRef); + + return newImage; +} + +// Returns an affine transform that takes into account the image orientation when drawing a scaled image +- (CGAffineTransform)transformForOrientation:(CGSize)newSize { + CGAffineTransform transform = CGAffineTransformIdentity; + + switch (self.imageOrientation) { + case UIImageOrientationDown: // EXIF = 3 + case UIImageOrientationDownMirrored: // EXIF = 4 + transform = CGAffineTransformTranslate(transform, newSize.width, newSize.height); + transform = CGAffineTransformRotate(transform, M_PI); + break; + + case UIImageOrientationLeft: // EXIF = 6 + case UIImageOrientationLeftMirrored: // EXIF = 5 + transform = CGAffineTransformTranslate(transform, newSize.width, 0); + transform = CGAffineTransformRotate(transform, M_PI_2); + break; + + case UIImageOrientationRight: // EXIF = 8 + case UIImageOrientationRightMirrored: // EXIF = 7 + transform = CGAffineTransformTranslate(transform, 0, newSize.height); + transform = CGAffineTransformRotate(transform, -M_PI_2); + break; + } + + switch (self.imageOrientation) { + case UIImageOrientationUpMirrored: // EXIF = 2 + case UIImageOrientationDownMirrored: // EXIF = 4 + transform = CGAffineTransformTranslate(transform, newSize.width, 0); + transform = CGAffineTransformScale(transform, -1, 1); + break; + + case UIImageOrientationLeftMirrored: // EXIF = 5 + case UIImageOrientationRightMirrored: // EXIF = 7 + transform = CGAffineTransformTranslate(transform, newSize.height, 0); + transform = CGAffineTransformScale(transform, -1, 1); + break; + } + + return transform; +} + +@end diff --git a/Classes/UIKit/UIImage+RoundedCorner.h b/Classes/UIKit/UIImage+RoundedCorner.h new file mode 100644 index 0000000..630ebb3 --- /dev/null +++ b/Classes/UIKit/UIImage+RoundedCorner.h @@ -0,0 +1,9 @@ +// UIImage+RoundedCorner.h +// Created by Trevor Harmon on 9/20/09. +// Free for personal or commercial use, with or without modification. +// No warranty is expressed or implied. + +// Extends the UIImage class to support making rounded corners +@interface UIImage (RoundedCorner) +- (UIImage *)roundedCornerImage:(NSInteger)cornerSize borderSize:(NSInteger)borderSize; +@end diff --git a/Classes/UIKit/UIImage+RoundedCorner.m b/Classes/UIKit/UIImage+RoundedCorner.m new file mode 100644 index 0000000..ed4cc41 --- /dev/null +++ b/Classes/UIKit/UIImage+RoundedCorner.m @@ -0,0 +1,79 @@ +// UIImage+RoundedCorner.m +// Created by Trevor Harmon on 9/20/09. +// Free for personal or commercial use, with or without modification. +// No warranty is expressed or implied. + +#import "UIImage+RoundedCorner.h" +#import "UIImage+Alpha.h" + +// Private helper methods +@interface UIImage () +- (void)addRoundedRectToPath:(CGRect)rect context:(CGContextRef)context ovalWidth:(CGFloat)ovalWidth ovalHeight:(CGFloat)ovalHeight; +@end + +@implementation UIImage (RoundedCorner) + +// Creates a copy of this image with rounded corners +// If borderSize is non-zero, a transparent border of the given size will also be added +// Original author: Björn Sållarp. Used with permission. See: http://blog.sallarp.com/iphone-uiimage-round-corners/ +- (UIImage *)roundedCornerImage:(NSInteger)cornerSize borderSize:(NSInteger)borderSize { + // If the image does not have an alpha layer, add one + UIImage *image = [self imageWithAlpha]; + + // Build a context that's the same dimensions as the new size + CGContextRef context = CGBitmapContextCreate(NULL, + image.size.width, + image.size.height, + CGImageGetBitsPerComponent(image.CGImage), + 0, + CGImageGetColorSpace(image.CGImage), + CGImageGetBitmapInfo(image.CGImage)); + + // Create a clipping path with rounded corners + CGContextBeginPath(context); + [self addRoundedRectToPath:CGRectMake(borderSize, borderSize, image.size.width - borderSize * 2, image.size.height - borderSize * 2) + context:context + ovalWidth:cornerSize + ovalHeight:cornerSize]; + CGContextClosePath(context); + CGContextClip(context); + + // Draw the image to the context; the clipping path will make anything outside the rounded rect transparent + CGContextDrawImage(context, CGRectMake(0, 0, image.size.width, image.size.height), image.CGImage); + + // Create a CGImage from the context + CGImageRef clippedImage = CGBitmapContextCreateImage(context); + CGContextRelease(context); + + // Create a UIImage from the CGImage + UIImage *roundedImage = [UIImage imageWithCGImage:clippedImage]; + CGImageRelease(clippedImage); + + return roundedImage; +} + +#pragma mark - +#pragma mark Private helper methods + +// Adds a rectangular path to the given context and rounds its corners by the given extents +// Original author: Björn Sållarp. Used with permission. See: http://blog.sallarp.com/iphone-uiimage-round-corners/ +- (void)addRoundedRectToPath:(CGRect)rect context:(CGContextRef)context ovalWidth:(CGFloat)ovalWidth ovalHeight:(CGFloat)ovalHeight { + if (ovalWidth == 0 || ovalHeight == 0) { + CGContextAddRect(context, rect); + return; + } + CGContextSaveGState(context); + CGContextTranslateCTM(context, CGRectGetMinX(rect), CGRectGetMinY(rect)); + CGContextScaleCTM(context, ovalWidth, ovalHeight); + CGFloat fw = CGRectGetWidth(rect) / ovalWidth; + CGFloat fh = CGRectGetHeight(rect) / ovalHeight; + CGContextMoveToPoint(context, fw, fh/2); + CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 1); + CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 1); + CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 1); + CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1); + CGContextClosePath(context); + CGContextRestoreGState(context); +} + +@end diff --git a/Classes/UIKit/UIImageView+LRAdditions.h b/Classes/UIKit/UIImageView+LRAdditions.h new file mode 100644 index 0000000..78c0b0a --- /dev/null +++ b/Classes/UIKit/UIImageView+LRAdditions.h @@ -0,0 +1,16 @@ +// +// UIImageView+ImageLoading.h +// Firelight +// +// Created by Luke Redpath on 18/05/2010. +// Copyright 2010 LJR Software Limited. All rights reserved. +// + +#import + + +@interface UIImageView (LRAdditions) + ++ (id)imageViewWithImageNamed:(NSString *)imageName; + +@end diff --git a/Classes/UIKit/UIImageView+LRAdditions.m b/Classes/UIKit/UIImageView+LRAdditions.m new file mode 100644 index 0000000..fef2efd --- /dev/null +++ b/Classes/UIKit/UIImageView+LRAdditions.m @@ -0,0 +1,21 @@ +// +// UIImageView+ImageLoading.m +// Firelight +// +// Created by Luke Redpath on 18/05/2010. +// Copyright 2010 LJR Software Limited. All rights reserved. +// + +#import "UIImageView+LRAdditions.h" + + +@implementation UIImageView (LRAdditions) + ++ (id)imageViewWithImageNamed:(NSString *)imageName; +{ + UIImage *image = [UIImage imageNamed:imageName]; + UIImageView *imageView = [[self alloc] initWithImage:image]; + return [imageView autorelease]; +} + +@end diff --git a/Classes/UIKit/UIToolbar+LRAdditions.h b/Classes/UIKit/UIToolbar+LRAdditions.h new file mode 100644 index 0000000..2d000c4 --- /dev/null +++ b/Classes/UIKit/UIToolbar+LRAdditions.h @@ -0,0 +1,16 @@ +// +// UIToolbar+SwapItem.h +// Flare +// +// Created by Luke Redpath on 17/06/2010. +// Copyright 2010 LJR Software Limited. All rights reserved. +// + +#import + + +@interface UIToolbar (LRAdditions) + +- (void)swapBarItem:(UIBarItem *)oldItem withItem:(UIBarItem *)newItem; + +@end diff --git a/Classes/UIKit/UIToolbar+LRAdditions.m b/Classes/UIKit/UIToolbar+LRAdditions.m new file mode 100644 index 0000000..4d687e9 --- /dev/null +++ b/Classes/UIKit/UIToolbar+LRAdditions.m @@ -0,0 +1,26 @@ +// +// UIToolbar+SwapItem.m +// Flare +// +// Created by Luke Redpath on 17/06/2010. +// Copyright 2010 LJR Software Limited. All rights reserved. +// + +#import "UIToolbar+LRAdditions.h" + + +@implementation UIToolbar (LRAdditions) + +- (void)swapBarItem:(UIBarItem *)oldItem withItem:(UIBarItem *)newItem; +{ + NSMutableArray *currentItems = [self.items mutableCopy]; + if (![currentItems containsObject:oldItem]) { + NSLog(@"Warning: tried to swap out %@ from toolbar %@ items when it doesn't exist", oldItem, self); + return; + } + NSInteger indexOfOldItem = [currentItems indexOfObject:oldItem]; + [currentItems replaceObjectAtIndex:indexOfOldItem withObject:newItem]; + [self setItems:currentItems]; +} + +@end diff --git a/Classes/UIKit/UIView+Position.h b/Classes/UIKit/UIView+Position.h new file mode 100644 index 0000000..8c9a586 --- /dev/null +++ b/Classes/UIKit/UIView+Position.h @@ -0,0 +1,27 @@ +// +// UIView+Position.h +// Spark +// +// Created by Luke Redpath on 25/05/2010. +// Copyright 2010 LJR Software Limited. All rights reserved. +// + +#import + + +@interface UIView (Position) + +@property (nonatomic) CGPoint frameOrigin; +@property (nonatomic) CGSize frameSize; + +@property (nonatomic) CGFloat frameX; +@property (nonatomic) CGFloat frameY; + +// Setting these modifies the origin but not the size. +@property (nonatomic) CGFloat frameRight; +@property (nonatomic) CGFloat frameBottom; + +@property (nonatomic) CGFloat frameWidth; +@property (nonatomic) CGFloat frameHeight; + +@end diff --git a/Classes/UIKit/UIView+Position.m b/Classes/UIKit/UIView+Position.m new file mode 100644 index 0000000..f18bdfc --- /dev/null +++ b/Classes/UIKit/UIView+Position.m @@ -0,0 +1,85 @@ +// +// UIView+Position.m +// Spark +// +// Created by Luke Redpath on 25/05/2010. +// Copyright 2010 LJR Software Limited. All rights reserved. +// + +#import "UIView+Position.h" + + +@implementation UIView (Position) + +- (CGPoint)frameOrigin { + return self.frame.origin; +} + +- (void)setFrameOrigin:(CGPoint)newOrigin { + self.frame = CGRectMake(newOrigin.x, newOrigin.y, self.frame.size.width, self.frame.size.height); +} + +- (CGSize)frameSize { + return self.frame.size; +} + +- (void)setFrameSize:(CGSize)newSize { + self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, + newSize.width, newSize.height); +} + +- (CGFloat)frameX { + return self.frame.origin.x; +} + +- (void)setFrameX:(CGFloat)newX { + self.frame = CGRectMake(newX, self.frame.origin.y, + self.frame.size.width, self.frame.size.height); +} + +- (CGFloat)frameY { + return self.frame.origin.y; +} + +- (void)setFrameY:(CGFloat)newY { + self.frame = CGRectMake(self.frame.origin.x, newY, + self.frame.size.width, self.frame.size.height); +} + +- (CGFloat)frameRight { + return self.frame.origin.x + self.frame.size.width; +} + +- (void)setFrameRight:(CGFloat)newRight { + self.frame = CGRectMake(newRight - self.frame.size.width, self.frame.origin.y, + self.frame.size.width, self.frame.size.height); +} + +- (CGFloat)frameBottom { + return self.frame.origin.y + self.frame.size.height; +} + +- (void)setFrameBottom:(CGFloat)newBottom { + self.frame = CGRectMake(self.frame.origin.x, newBottom - self.frame.size.height, + self.frame.size.width, self.frame.size.height); +} + +- (CGFloat)frameWidth { + return self.frame.size.width; +} + +- (void)setFrameWidth:(CGFloat)newWidth { + self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, + newWidth, self.frame.size.height); +} + +- (CGFloat)frameHeight { + return self.frame.size.height; +} + +- (void)setFrameHeight:(CGFloat)newHeight { + self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, + self.frame.size.width, newHeight); +} + +@end diff --git a/LRToolkit.xcodeproj/project.pbxproj b/LRToolkit.xcodeproj/project.pbxproj index 74d203b..ea2303c 100644 --- a/LRToolkit.xcodeproj/project.pbxproj +++ b/LRToolkit.xcodeproj/project.pbxproj @@ -7,11 +7,63 @@ objects = { /* Begin PBXBuildFile section */ + A387AD1F11CE9215000865EE /* UIImage+Alpha.h in Headers */ = {isa = PBXBuildFile; fileRef = A387AD1911CE9215000865EE /* UIImage+Alpha.h */; }; + A387AD2011CE9215000865EE /* UIImage+Alpha.m in Sources */ = {isa = PBXBuildFile; fileRef = A387AD1A11CE9215000865EE /* UIImage+Alpha.m */; }; + A387AD2111CE9215000865EE /* UIImage+RoundedCorner.h in Headers */ = {isa = PBXBuildFile; fileRef = A387AD1B11CE9215000865EE /* UIImage+RoundedCorner.h */; }; + A387AD2211CE9215000865EE /* UIImage+RoundedCorner.m in Sources */ = {isa = PBXBuildFile; fileRef = A387AD1C11CE9215000865EE /* UIImage+RoundedCorner.m */; }; + A387AD2311CE9215000865EE /* UIImage+Resize.h in Headers */ = {isa = PBXBuildFile; fileRef = A387AD1D11CE9215000865EE /* UIImage+Resize.h */; }; + A387AD2411CE9215000865EE /* UIImage+Resize.m in Sources */ = {isa = PBXBuildFile; fileRef = A387AD1E11CE9215000865EE /* UIImage+Resize.m */; }; + A387AD2711CE9244000865EE /* UIColor+Hex.h in Headers */ = {isa = PBXBuildFile; fileRef = A387AD2511CE9244000865EE /* UIColor+Hex.h */; }; + A387AD2811CE9244000865EE /* UIColor+Hex.m in Sources */ = {isa = PBXBuildFile; fileRef = A387AD2611CE9244000865EE /* UIColor+Hex.m */; }; + A387AD2F11CE9253000865EE /* UIImageView+LRAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = A387AD2911CE9253000865EE /* UIImageView+LRAdditions.h */; }; + A387AD3011CE9253000865EE /* UIImageView+LRAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = A387AD2A11CE9253000865EE /* UIImageView+LRAdditions.m */; }; + A387AD3111CE9253000865EE /* UIView+Position.h in Headers */ = {isa = PBXBuildFile; fileRef = A387AD2B11CE9253000865EE /* UIView+Position.h */; }; + A387AD3211CE9253000865EE /* UIView+Position.m in Sources */ = {isa = PBXBuildFile; fileRef = A387AD2C11CE9253000865EE /* UIView+Position.m */; }; + A387AD3311CE9253000865EE /* UIToolbar+LRAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = A387AD2D11CE9253000865EE /* UIToolbar+LRAdditions.h */; }; + A387AD3411CE9253000865EE /* UIToolbar+LRAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = A387AD2E11CE9253000865EE /* UIToolbar+LRAdditions.m */; }; + A387AD4211CE927B000865EE /* NSData+Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = A387AD3611CE927B000865EE /* NSData+Base64.h */; }; + A387AD4311CE927B000865EE /* NSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = A387AD3711CE927B000865EE /* NSData+Base64.m */; }; + A387AD4411CE927B000865EE /* NSString+Hashing.h in Headers */ = {isa = PBXBuildFile; fileRef = A387AD3811CE927B000865EE /* NSString+Hashing.h */; }; + A387AD4511CE927B000865EE /* NSString+Hashing.m in Sources */ = {isa = PBXBuildFile; fileRef = A387AD3911CE927B000865EE /* NSString+Hashing.m */; }; + A387AD4611CE927B000865EE /* NSArray+Indexing.h in Headers */ = {isa = PBXBuildFile; fileRef = A387AD3A11CE927B000865EE /* NSArray+Indexing.h */; }; + A387AD4711CE927B000865EE /* NSArray+Indexing.m in Sources */ = {isa = PBXBuildFile; fileRef = A387AD3B11CE927B000865EE /* NSArray+Indexing.m */; }; + A387AD4811CE927B000865EE /* NSURL+StringFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = A387AD3C11CE927B000865EE /* NSURL+StringFormat.h */; }; + A387AD4911CE927B000865EE /* NSURL+StringFormat.m in Sources */ = {isa = PBXBuildFile; fileRef = A387AD3D11CE927B000865EE /* NSURL+StringFormat.m */; }; + A387AD4A11CE927B000865EE /* NSString+GHTimeInterval.h in Headers */ = {isa = PBXBuildFile; fileRef = A387AD3E11CE927B000865EE /* NSString+GHTimeInterval.h */; }; + A387AD4B11CE927B000865EE /* NSString+GHTimeInterval.m in Sources */ = {isa = PBXBuildFile; fileRef = A387AD3F11CE927B000865EE /* NSString+GHTimeInterval.m */; }; + A387AD4C11CE927B000865EE /* NSString+FileSize.h in Headers */ = {isa = PBXBuildFile; fileRef = A387AD4011CE927B000865EE /* NSString+FileSize.h */; }; + A387AD4D11CE927B000865EE /* NSString+FileSize.m in Sources */ = {isa = PBXBuildFile; fileRef = A387AD4111CE927B000865EE /* NSString+FileSize.m */; }; AA747D9F0F9514B9006C5449 /* LRToolkit_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* LRToolkit_Prefix.pch */; }; AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + A387AD1911CE9215000865EE /* UIImage+Alpha.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+Alpha.h"; sourceTree = ""; }; + A387AD1A11CE9215000865EE /* UIImage+Alpha.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Alpha.m"; sourceTree = ""; }; + A387AD1B11CE9215000865EE /* UIImage+RoundedCorner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+RoundedCorner.h"; sourceTree = ""; }; + A387AD1C11CE9215000865EE /* UIImage+RoundedCorner.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+RoundedCorner.m"; sourceTree = ""; }; + A387AD1D11CE9215000865EE /* UIImage+Resize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+Resize.h"; sourceTree = ""; }; + A387AD1E11CE9215000865EE /* UIImage+Resize.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Resize.m"; sourceTree = ""; }; + A387AD2511CE9244000865EE /* UIColor+Hex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+Hex.h"; sourceTree = ""; }; + A387AD2611CE9244000865EE /* UIColor+Hex.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+Hex.m"; sourceTree = ""; }; + A387AD2911CE9253000865EE /* UIImageView+LRAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+LRAdditions.h"; sourceTree = ""; }; + A387AD2A11CE9253000865EE /* UIImageView+LRAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+LRAdditions.m"; sourceTree = ""; }; + A387AD2B11CE9253000865EE /* UIView+Position.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+Position.h"; sourceTree = ""; }; + A387AD2C11CE9253000865EE /* UIView+Position.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+Position.m"; sourceTree = ""; }; + A387AD2D11CE9253000865EE /* UIToolbar+LRAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIToolbar+LRAdditions.h"; sourceTree = ""; }; + A387AD2E11CE9253000865EE /* UIToolbar+LRAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIToolbar+LRAdditions.m"; sourceTree = ""; }; + A387AD3611CE927B000865EE /* NSData+Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+Base64.h"; sourceTree = ""; }; + A387AD3711CE927B000865EE /* NSData+Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+Base64.m"; sourceTree = ""; }; + A387AD3811CE927B000865EE /* NSString+Hashing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Hashing.h"; sourceTree = ""; }; + A387AD3911CE927B000865EE /* NSString+Hashing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Hashing.m"; sourceTree = ""; }; + A387AD3A11CE927B000865EE /* NSArray+Indexing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+Indexing.h"; sourceTree = ""; }; + A387AD3B11CE927B000865EE /* NSArray+Indexing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+Indexing.m"; sourceTree = ""; }; + A387AD3C11CE927B000865EE /* NSURL+StringFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSURL+StringFormat.h"; sourceTree = ""; }; + A387AD3D11CE927B000865EE /* NSURL+StringFormat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSURL+StringFormat.m"; sourceTree = ""; }; + A387AD3E11CE927B000865EE /* NSString+GHTimeInterval.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+GHTimeInterval.h"; sourceTree = ""; }; + A387AD3F11CE927B000865EE /* NSString+GHTimeInterval.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+GHTimeInterval.m"; sourceTree = ""; }; + A387AD4011CE927B000865EE /* NSString+FileSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+FileSize.h"; sourceTree = ""; }; + A387AD4111CE927B000865EE /* NSString+FileSize.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+FileSize.m"; sourceTree = ""; }; AA747D9E0F9514B9006C5449 /* LRToolkit_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LRToolkit_Prefix.pch; sourceTree = SOURCE_ROOT; }; AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; D2AAC07E0554694100DB518D /* libLRToolkit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libLRToolkit.a; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -77,6 +129,7 @@ A35ED82A11CE802300055268 /* Foundation */ = { isa = PBXGroup; children = ( + A387AD3511CE925E000865EE /* Categories */, ); path = Foundation; sourceTree = ""; @@ -84,6 +137,7 @@ A35ED82B11CE802300055268 /* UIKit */ = { isa = PBXGroup; children = ( + A387AD1411CE91FD000865EE /* Categories */, ); path = UIKit; sourceTree = ""; @@ -95,6 +149,46 @@ name = Specs; sourceTree = ""; }; + A387AD1411CE91FD000865EE /* Categories */ = { + isa = PBXGroup; + children = ( + A387AD2911CE9253000865EE /* UIImageView+LRAdditions.h */, + A387AD2A11CE9253000865EE /* UIImageView+LRAdditions.m */, + A387AD2B11CE9253000865EE /* UIView+Position.h */, + A387AD2C11CE9253000865EE /* UIView+Position.m */, + A387AD2D11CE9253000865EE /* UIToolbar+LRAdditions.h */, + A387AD2E11CE9253000865EE /* UIToolbar+LRAdditions.m */, + A387AD2511CE9244000865EE /* UIColor+Hex.h */, + A387AD2611CE9244000865EE /* UIColor+Hex.m */, + A387AD1911CE9215000865EE /* UIImage+Alpha.h */, + A387AD1A11CE9215000865EE /* UIImage+Alpha.m */, + A387AD1B11CE9215000865EE /* UIImage+RoundedCorner.h */, + A387AD1C11CE9215000865EE /* UIImage+RoundedCorner.m */, + A387AD1D11CE9215000865EE /* UIImage+Resize.h */, + A387AD1E11CE9215000865EE /* UIImage+Resize.m */, + ); + name = Categories; + sourceTree = ""; + }; + A387AD3511CE925E000865EE /* Categories */ = { + isa = PBXGroup; + children = ( + A387AD3611CE927B000865EE /* NSData+Base64.h */, + A387AD3711CE927B000865EE /* NSData+Base64.m */, + A387AD3811CE927B000865EE /* NSString+Hashing.h */, + A387AD3911CE927B000865EE /* NSString+Hashing.m */, + A387AD3A11CE927B000865EE /* NSArray+Indexing.h */, + A387AD3B11CE927B000865EE /* NSArray+Indexing.m */, + A387AD3C11CE927B000865EE /* NSURL+StringFormat.h */, + A387AD3D11CE927B000865EE /* NSURL+StringFormat.m */, + A387AD3E11CE927B000865EE /* NSString+GHTimeInterval.h */, + A387AD3F11CE927B000865EE /* NSString+GHTimeInterval.m */, + A387AD4011CE927B000865EE /* NSString+FileSize.h */, + A387AD4111CE927B000865EE /* NSString+FileSize.m */, + ); + name = Categories; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -103,6 +197,19 @@ buildActionMask = 2147483647; files = ( AA747D9F0F9514B9006C5449 /* LRToolkit_Prefix.pch in Headers */, + A387AD1F11CE9215000865EE /* UIImage+Alpha.h in Headers */, + A387AD2111CE9215000865EE /* UIImage+RoundedCorner.h in Headers */, + A387AD2311CE9215000865EE /* UIImage+Resize.h in Headers */, + A387AD2711CE9244000865EE /* UIColor+Hex.h in Headers */, + A387AD2F11CE9253000865EE /* UIImageView+LRAdditions.h in Headers */, + A387AD3111CE9253000865EE /* UIView+Position.h in Headers */, + A387AD3311CE9253000865EE /* UIToolbar+LRAdditions.h in Headers */, + A387AD4211CE927B000865EE /* NSData+Base64.h in Headers */, + A387AD4411CE927B000865EE /* NSString+Hashing.h in Headers */, + A387AD4611CE927B000865EE /* NSArray+Indexing.h in Headers */, + A387AD4811CE927B000865EE /* NSURL+StringFormat.h in Headers */, + A387AD4A11CE927B000865EE /* NSString+GHTimeInterval.h in Headers */, + A387AD4C11CE927B000865EE /* NSString+FileSize.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -149,6 +256,19 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + A387AD2011CE9215000865EE /* UIImage+Alpha.m in Sources */, + A387AD2211CE9215000865EE /* UIImage+RoundedCorner.m in Sources */, + A387AD2411CE9215000865EE /* UIImage+Resize.m in Sources */, + A387AD2811CE9244000865EE /* UIColor+Hex.m in Sources */, + A387AD3011CE9253000865EE /* UIImageView+LRAdditions.m in Sources */, + A387AD3211CE9253000865EE /* UIView+Position.m in Sources */, + A387AD3411CE9253000865EE /* UIToolbar+LRAdditions.m in Sources */, + A387AD4311CE927B000865EE /* NSData+Base64.m in Sources */, + A387AD4511CE927B000865EE /* NSString+Hashing.m in Sources */, + A387AD4711CE927B000865EE /* NSArray+Indexing.m in Sources */, + A387AD4911CE927B000865EE /* NSURL+StringFormat.m in Sources */, + A387AD4B11CE927B000865EE /* NSString+GHTimeInterval.m in Sources */, + A387AD4D11CE927B000865EE /* NSString+FileSize.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };