ILTranslucentView 是 UIView 的一个子类,可以提供原生 iOS 7+ 睿智(半透明)效果。它可以在所有 iOS 设备上实时使用,没有任何性能问题。它还支持平滑的 UIView 颜色、框架、alpha 等动画。
ILTranslucentView *translucentView = [[ILTranslucentView alloc] initWithFrame:CGRectMake(0, 0, 250, 150)];
[self.view addSubview:translucentView]; //that's it :)
//optional:
translucentView.translucentAlpha = 1;
translucentView.translucentStyle = UIBarStyleDefault;
translucentView.translucentTintColor = [UIColor clearColor];
translucentView.backgroundColor = [UIColor clearColor];
var view = ILTranslucentView(frame: CGRectMake(0, 0, 250, 150)
self.view.addSubview(view)
view.translucentAlpha = 1
view.translucentStyle = UIBarStyle.Default
view.translucentTintColor = UIColor.clearColor()
view.backgroundColor = UIColor.clearColor()
半透明的 alpha 值。这个属性的值是一个 0.0 到 1.0 的浮点数,其中 0.0 表示无半透明白色,1.0 表示最大半透明效果。
注意:如果 translucentAlpha 未设置为 1.0,视图可能会失去模糊效果。
ILTranslucentView 使用 UIToolbar 提供半透明效果。这个属性指定了它的外观。
应用于半透明颜色的着色色。
对于 iOS 6-,这是视图的背景颜色。对于 iOS 7+,它表示半透明层之上层的背景颜色。
它工作,但没有透明白色效果。它表现得像一个普通的 UIView。尝试在 backgroundColor 上使用一些不透明度。
在 Identity Inspector 中添加自定义类:ILTranslucentView。