Skip to content

Commit

Permalink
Updated to version 1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Sep 3, 2013
1 parent 045b13e commit debfcec
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
4 changes: 2 additions & 2 deletions FXBlurView.podspec
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Pod::Spec.new do |s|
s.name = 'FXBlurView'
s.version = '1.3.1'
s.version = '1.3.2'
s.license = 'zlib'
s.summary = 'UIView subclass that replicates the iOS 7 realtime background blur effect, but works on iOS 5 and above.'
s.author = { 'Nick Lockwood' => 'http://charcoaldesign.co.uk/' }
s.source = { :git => 'https://github.com/nicklockwood/FXBlurView.git', :tag => '1.3.1' }
s.source = { :git => 'https://github.com/nicklockwood/FXBlurView.git', :tag => '1.3.2' }
s.homepage = 'http://github.com/nicklockwood/FXBlurView'
s.platform = :ios
s.source_files = 'FXBlurView'
Expand Down
2 changes: 1 addition & 1 deletion FXBlurView/FXBlurView.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FXBlurView.h
//
// Version 1.3.1
// Version 1.3.2
//
// Created by Nick Lockwood on 25/08/2013.
// Copyright (c) 2013 Charcoal Design
Expand Down
41 changes: 22 additions & 19 deletions FXBlurView/FXBlurView.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FXBlurView.m
//
// Version 1.3.1
// Version 1.3.2
//
// Created by Nick Lockwood on 25/08/2013.
// Copyright (c) 2013 Charcoal Design
Expand Down Expand Up @@ -207,14 +207,17 @@ - (void)setBlurRadius:(CGFloat)blurRadius
- (void)setDynamic:(BOOL)dynamic
{
_dynamicSet = YES;
_dynamic = dynamic;
if (dynamic)
if (_dynamic != dynamic)
{
[self updateAsynchronously];
}
else
{
[self setNeedsDisplay];
_dynamic = dynamic;
if (dynamic)
{
[self updateAsynchronously];
}
else
{
[self setNeedsDisplay];
}
}
}

Expand Down Expand Up @@ -246,12 +249,9 @@ - (void)displayLayer:(CALayer *)layer
{
if (self.superview)
{
NSArray *hiddenViews = [self prepareSuperviewForSnapshot:self.superview];
UIImage *snapshot = [self snapshotOfSuperview:self.superview];
[self restoreSuperviewAfterSnapshot:hiddenViews];
NSUInteger iterations = MAX(0, (NSInteger)self.iterations - 1);
UIImage *blurredImage = [snapshot blurredImageWithRadius:self.blurRadius
iterations:iterations
iterations:self.iterations
tintColor:self.tintColor];
self.layer.contents = (id)blurredImage.CGImage;
self.layer.contentsScale = blurredImage.scale;
Expand All @@ -260,11 +260,18 @@ - (void)displayLayer:(CALayer *)layer

- (UIImage *)snapshotOfSuperview:(UIView *)superview
{
CGFloat scale = (self.iterations > 0)? 8.0f/MAX(8, floor(self.blurRadius)): 1.0f;
CGFloat scale = 0.5;
if (self.iterations > 0 && ([UIScreen mainScreen].scale > 1 || self.contentMode == UIViewContentModeScaleAspectFill))
{
CGFloat blockSize = 12.0f/self.iterations;
scale = blockSize/MAX(blockSize * 2, floor(self.blurRadius));
}
UIGraphicsBeginImageContextWithOptions(self.bounds.size, YES, scale);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, -self.frame.origin.x, -self.frame.origin.y);
NSArray *hiddenViews = [self prepareSuperviewForSnapshot:superview];
[superview.layer renderInContext:context];
[self restoreSuperviewAfterSnapshot:hiddenViews];
UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return snapshot;
Expand Down Expand Up @@ -301,16 +308,12 @@ - (void)updateAsynchronously
{
if (self.dynamic && !self.updating && self.window && updatesEnabled > 0)
{
NSArray *hiddenViews = [self prepareSuperviewForSnapshot:self.superview];
UIImage *snapshot = [self snapshotOfSuperview:self.superview];
[self restoreSuperviewAfterSnapshot:hiddenViews];

self.updating = YES;
UIImage *snapshot = [self snapshotOfSuperview:self.superview];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{

NSUInteger iterations = MAX(0, (NSInteger)self.iterations - 1);
UIImage *blurredImage = [snapshot blurredImageWithRadius:self.blurRadius
iterations:iterations
iterations:self.iterations
tintColor:self.tintColor];
dispatch_sync(dispatch_get_main_queue(), ^{

Expand Down
2 changes: 1 addition & 1 deletion LICENCE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FXBlurView

Version 1.3.1, September 1st, 2013
Version 1.3.2, September 3rd, 2013

Copyright (C) 2013 Charcoal Design

Expand Down
5 changes: 5 additions & 0 deletions RELEASE NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Version 1.3.2

- Fixed issue with pixelation on non-Retina devices
- Tweaked performance/quality tradeoff

Version 1.3.1

- Improved blur quality (1.3 was slightly blocky)
Expand Down

0 comments on commit debfcec

Please sign in to comment.