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?
One solution to this problem is to detect when the device changed orientation and generate the Blur Effect and update the constraints each time
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With