我有一个 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;
}
这些按钮必须经常移动(平移)、调整大小和缩放,当我执行这些操作时,模糊消失并变成半透明 View 。如果我使用框架/中心移动,使用 CGAffineTransformation,就会发生这种情况。
有什么办法可以解决吗?
最佳答案
这个问题的一个解决方案是检测设备何时改变方向并生成模糊效果并每次更新约束
关于iOS 8 UIVisualEffect UIBlurEffect 和缩放/移动/调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27178982/