Skip to content

Instantly share code, notes, and snippets.

@Tricertops
Tricertops / emoji-clock.m
Last active September 2, 2015 11:27
Objective-C method that returns Emoji symbol of a clock for any given hour.
- (NSString *)clockForHour:(NSUInteger)hour {
NSArray *clocks = @[ @"🕛", @"🕐", @"🕑", @"🕒", @"🕓", @"🕔",
@"🕕", @"🕖", @"🕗", @"🕘", @"🕙", @"🕚" ];
NSUInteger index = hour % clocks.count;
return [clocks objectAtIndex:index];
}
@mpospese
mpospese / CGRectIntegralScaled.m
Created February 28, 2013 03:34
Pixel aligns rectangles, taking the device's screen scale into account.
CGRect CGRectIntegralScaledEx(CGRect rect, CGFloat scale)
{
return CGRectMake(floorf(rect.origin.x * scale) / scale, floorf(rect.origin.y * scale) / scale, ceilf(rect.size.width * scale) / scale, ceilf(rect.size.height * scale) / scale);
}
CGRect CGRectIntegralScaled(CGRect rect)
{
return CGRectIntegralScaledEx(rect, [[UIScreen mainScreen] scale]);
}