Created
May 1, 2013 08:03
-
-
Save kenshin03/5494256 to your computer and use it in GitHub Desktop.
ascync loading background image and extracting its background color with LEColorPicker
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
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
if (!self.imageURLString){ | |
self.imageURLString = self.sourceAvartarImageURL; | |
self.backgroundImageView.contentMode = UIViewContentModeScaleAspectFill; | |
} | |
UIImage * feedImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.imageURLString]]]; | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
self.backgroundImageView.alpha = 0.0f; | |
self.backgroundImageView.image = feedImage; | |
[LEColorPicker pickColorFromImage:feedImage onComplete:^(NSDictionary *colorsPickedDictionary) { | |
[UIView beginAnimations:@"ColorChange" context:nil]; | |
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut]; | |
[UIView setAnimationDuration:0.5]; | |
self.view.backgroundColor = colorsPickedDictionary[@"BackgroundColor"]; | |
[UIView commitAnimations]; | |
}]; | |
[UIView animateWithDuration:0.3f delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^{ | |
self.backgroundImageView.alpha = 1.0f; | |
} completion:^(BOOL finished) { | |
}]; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment