This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (CMAcceleration)platformSpecificAcceleration; | |
{ | |
CMAcceleration acceleration = self.motionManager.accelerometerData.acceleration; | |
#if (TARGET_OS_SIMULATOR) | |
acceleration = (CMAcceleration){ | |
UIDevice.currentDevice.orientation == UIDeviceOrientationLandscapeLeft ? -1.f : | |
UIDevice.currentDevice.orientation == UIDeviceOrientationLandscapeRight ? 1.f : 0.f, | |
UIDevice.currentDevice.orientation == UIDeviceOrientationPortrait ? -1.f : | |
UIDevice.currentDevice.orientation == UIDeviceOrientationPortraitUpsideDown ? 1.f : 0.f, 0.f}; | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGImageRef image = (__bridge CGImageRef)self.view.layer.contents; | |
CGDataProviderRef dataProviderRef = CGImageGetDataProvider(image); | |
CFDataRef dataRef = CGDataProviderCopyData(dataProviderRef); | |
void *dataBytePointer = (void *)CFDataGetBytePtr(dataRef); | |
CGColorSpaceRef colorSpace = CGImageGetColorSpace(image); | |
CGContextRef context = CGBitmapContextCreateWithData(dataBytePointer, CGImageGetWidth(image), CGImageGetHeight(image), CGImageGetBitsPerComponent(image), CGImageGetBytesPerRow(image), colorSpace, CGImageGetBitmapInfo(image), NULL, NULL); | |
CGContextDoWhatever(context)... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assumes ARGB8888 | |
CGImageRef CGImageCreateBlurredImage(CGImageRef inImage, NSUInteger blurRadius) | |
{ | |
if (!inImage) { return NULL; } | |
uint32_t radius = (blurRadius % 2) ? (uint32_t)blurRadius : (uint32_t)++blurRadius; | |
vImage_Error error; | |
vImage_CGImageFormat imageFormat = {(uint32_t)CGImageGetBitsPerComponent(inImage), (uint32_t)CGImageGetBitsPerPixel(inImage), CGImageGetColorSpace(inImage), CGImageGetBitmapInfo(inImage), 0, NULL, kCGRenderingIntentDefault}; | |
vImage_Buffer source; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface NSArray (StringUtilities) | |
- (NSString *)string; | |
@end | |
@implementation NSArray (StringUtilities) | |
- (NSString *)string { return [self componentsJoinedByString:@""]; } | |
@end | |
// Usage Example: NSString *test = @[ @"This", @" is", @" a", @" test." ].string; |