我的代码
UIImageView *backImageView = [[UIImageView alloc]initWithFrame:_discorverCollerction.bounds]; backImageView.image = [UIImage imageNamed:@"sea.jpg"]; UIBlurEffect *beffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight]; UIVisualEffectView *effectview = [[UIVisualEffectView alloc]initWithEffect:beffect]; effectview.frame = backImageView.bounds; [backImageView addSubview:effectview]; _discorverCollerction.backgroundView = backImageView;My code
UIImageView *backImageView = [[UIImageView alloc]initWithFrame:_discorverCollerction.bounds]; backImageView.image = [UIImage imageNamed:@"sea.jpg"]; UIBlurEffect *beffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight]; UIVisualEffectView *effectview = [[UIVisualEffectView alloc]initWithEffect:beffect]; effectview.frame = backImageView.bounds; [backImageView addSubview:effectview]; _discorverCollerction.backgroundView = backImageView;最满意答案
我怀疑你的问题是“为什么这不起作用?”。
阅读精细手册 ,看看,你没有使用该权利。 将UIVisualEffectView添加到UIVisualEffectView的contentView 。
UIVisualEffectView对象为您提供了一种实现一些复杂视觉效果的简便方法。 根据所需的效果,效果可能会影响视图后面的内容或添加到视觉效果视图的contentView的内容。
将视觉效果视图应用于现有视图,然后应用UIBlurEffect或UIVibrancyEffect对象以将模糊或活力效果应用于现有视图。 将视觉效果视图添加到视图层次结构后,将任何子视图添加到视觉效果视图的contentView属性。 不要将子视图直接添加到视觉效果视图本身。
I suspect your question to be "Why doesn't this work?".
Read the fine manual and see, you didn't use that right. Add the imageView to the UIVisualEffectView's contentView.
A UIVisualEffectView object gives you an easy way implement some complex visual effects. Depending on the desired effect, the effect may affect content layered behind the view or content added to the visual effect view’s contentView.
Apply a visual effect view to an existing view and then apply a UIBlurEffect or UIVibrancyEffect object to apply a blur or vibrancy effect to the existing view. After you add the visual effect view to the view hierarchy, add any subviews to the contentView property of the visual effect view. Do not add subviews directly to the visual effect view itself.
更多推荐
发布评论