Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 8 UIVisualEffect UIBlurEffect and Scaling/Moving/Resizing

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?

like image 366
Gizmodo Avatar asked Nov 10 '22 22:11

Gizmodo


1 Answers

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

like image 104
BlackM Avatar answered Nov 14 '22 22:11

BlackM