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?

Matthias Bauch
  • 89,811
  • 20
  • 225
  • 247
Gizmodo
  • 3,151
  • 7
  • 45
  • 92

1 Answers1

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

BlackM
  • 3,927
  • 8
  • 39
  • 69