This is how I blur a UIImage called artworkImage
using UIImage+Effects
to get the iOS 7 blur effect:
-(void)viewDidAppear:(BOOL)animated{
MPMediaItem *currentItem = [self.musicPlayer nowPlayingItem];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul), ^(void) {
@autoreleasepool {
MPMediaItemArtwork *artwork = [currentItem valueForProperty: MPMediaItemPropertyArtwork];
UIImage *artworkImage = [artwork imageWithSize: CGSizeMake (618, 618)];
artworkImage = [artworkImage applyDarkEffect];
dispatch_async(dispatch_get_main_queue(), ^{
[backgroundImageView setImage:artworkImage];
UIGraphicsEndImageContext();
});
}
});
}
My app is really slow so I researched how to find out why, and I came across Instruments, which showed me this:
So I researched some more how to solve this, and came across dispatch_async
, so I put the actual blurring into the background and updating the UI in the front. It's still terribly slow.
This UIImage
called artworkImage
updates every time the music player skips song. I apply the iOS 7 blur effect from Apple's sample projects, called UIImage+Effects.h
, to this UIImage.
Please advise me on what to do - I've searched countless threads which all say use autorelease
, which I can't of course use with ARC.
Any help would be much appreciated, thanks.