在需要模糊的UIView上,添加一個UIVisualEffectView對象即可。
效果如下圖:
<喎?/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+tPrC68jnz8KjujwvcD4KPHA+PGJyPgo8L3A+CjxwPjwvcD4KPHA+CiAgICBVSUltYWdlVmlldyAqaW1hZ2V2aWV3ID0gW1tVSUltYWdlVmlldwphbGxvY10gCmluaXRdOzwvcD4KPHA+ICAgIGltYWdldmlldy5mcmFtZSA9CkNHUmVjdE1ha2UoMTAsCjEwMCwgMzAwLCAKMzAwKTs8L3A+CjxwPiAgICBpbWFnZXZpZXcuaW1hZ2UgPSBbVUlJbWFnZQppbWFnZU5hbWVkOkA="2"];
imageview.contentMode = UIViewContentModeScaleAspectFit;
imageview.userInteractionEnabled = YES;
[self.view addSubview:imageview];
UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *effectview = [[UIVisualEffectView alloc] initWithEffect:blur];
effectview.frame = CGRectMake(0, 0, imageview.size.width/2, 300);
[imageview addSubview:effectview];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
btn.frame = CGRectMake(10, 50, 100, 40);
[btn setTitle:@"btn" forState:UIControlStateNormal];
[effectview.contentView addSubview:btn];
iOS開發 swift技術交流QQ群361513739