iOS 8 UIVisualEffect UIBlurEffect and Scaling/Moving/Resizing

945 views Asked by At

I have a subclass of a UIButton that I am blurring and it looks great:

- (id)initWithFrame:(CGRect)frame
    {
        if (self = [super initWithFrame:frame])
        {
            self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.0];
            UIVisualEffect *blurEffect;
            blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];

            UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
            visualEffectView.frame = self.bounds;

            [self insertSubview:visualEffectView atIndex:0];
            visualEffectView.userInteractionEnabled = NO;

            self.layer.cornerRadius = 23.8;
            self.clipsToBounds = YES;

            self.titleLabel.font = [UIFont fontWithName:@"DINCondensed-Bold" size:15.0];
        }
        return self;
    }

These buttons have to move(translate), resize, and scale often and the blur goes away and become a semi transparent view when I am performing those actions. This happens if I am moving using the frame/center, of using CGAffineTransformation.

Is there a way to cure this?

1

There are 1 answers

0
BlackM On

One solution to this problem is to detect when the device changed orientation and generate the Blur Effect and update the constraints each time