iOS 8 UIVisualEffect UIBlurEffect and Scaling/Moving/Resizing
Asked Answered
P

1

6

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?

Praedial answered 27/11, 2014 at 21:38 Comment(1)
Does the user tap the button to trigger the transform?Swart
U
1

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

Ursel answered 30/3, 2015 at 13:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.