5

我有一个 UIButton 的子类,我正在模糊它,它看起来很棒:

- (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;
    }

这些按钮必须经常移动(平移)、调整大小和缩放,当我执行这些操作时,模糊消失并变成半透明视图。如果我使用 CGAffineTransformation 的框架/中心移动,就会发生这种情况。

有没有办法治愈这个?

4

1 回答 1

1

此问题的一种解决方案是检测设备何时改变方向并生成模糊效果并每次更新约束

于 2015-03-30T13:42:53.420 回答