如何制作一个看起来和UIAlertView一模一样的UIView?

Had*_*adi 0 appearance uialertview ios

我想在屏幕上显示一些标签,并且想让它们看起来与 UIAlertView 完全相同。如何复制外观?请注意,我不关心警报视图的任何功能,只想要默认外观,因为它看起来不错。未设置 UIAlertView 上的 backgroundColor 等常见属性,并且 CALayer 的属性未显示任何有用的内容。

有任何想法吗?

Ver*_*ant 5

您正在寻找的是模糊效果。如果您的目标是 iOS 8 及更高版本,您可以使用它来创建模糊视图

UIBlurEffect* blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];
    effectView = [[UIVisualEffectView alloc] initWithEffect:blur];
    effectView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    effectView.frame = self.bounds;
    [self addSubview:effectView];
Run Code Online (Sandbox Code Playgroud)

苹果文档

请注意,您可以使用 UIBlurEffectStyleExtraLight、UIBlurEffectStyleLight、UIBlurEffectStyleDark。

如果您使用较低版本的 iOS,则必须使用像FXBlurView这样的自定义类。