Skip to content

Instantly share code, notes, and snippets.

@rpitting
rpitting / gist:4753669
Last active December 12, 2015 09:39
Well, I really did not notice this really slooooooooooow fadeout of my *beautiful* scrollview shadows.
- (void) fadeOutShadowsSuchThatReinerWontNotice
{
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-dd HH:mm:ss zzz"];
NSDate *fadeOutStartDate = [df dateFromString:@"2013-01-21 15:00:00 +0100"];
NSDate *fadeOutEndDate = [df dateFromString:@"2013-01-25 18:00:00 +0100"];
NSDate *now = [NSDate date];
float blendValue = (now.timeIntervalSince1970 - fadeOutStartDate.timeIntervalSince1970) /
(fadeOutEndDate.timeIntervalSince1970 - fadeOutStartDate.timeIntervalSince1970);
@rpitting
rpitting / gist:4663066
Created January 29, 2013 09:42
Loading an image in den background queue, and assigning it to an image view in the main queue. Is this a good pattern?
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
UIImage* image = [UIImage imageWithContentsOfFile:...];
dispatch_async(dispatch_get_main_queue(), ^{
self.targetImageView.image = image;
});
});