ILTranslucentView 0.1

ILTranslucentView 0.1

测试测试过
Lang语言 SwiftSwift
许可证 MIT
发布最新发布2015年3月
SPM支持 SPM

Ivo Leko 维护。



  • 作者
  • ivoleko

ILTranslucentView (iOS, Objective-C, Swift)

ILTranslucentView 是 UIView 的一个子类,可以提供原生 iOS 7+ 睿智(半透明)效果。它可以在所有 iOS 设备上实时使用,没有任何性能问题。它还支持平滑的 UIView 颜色、框架、alpha 等动画。

如何使用它

  • 将源文件夹中的 ILTranslucentView.h 和 ILTranslucentView.m 添加到您的项目中
  • 将它用作普通的 UIView,但有额外的函数/属性
    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()

translucentAlpha

半透明的 alpha 值。这个属性的值是一个 0.0 到 1.0 的浮点数,其中 0.0 表示无半透明白色,1.0 表示最大半透明效果。
注意:如果 translucentAlpha 未设置为 1.0,视图可能会失去模糊效果。

translucentStyle

ILTranslucentView 使用 UIToolbar 提供半透明效果。这个属性指定了它的外观。

translucentTintColor

应用于半透明颜色的着色色。

backgroundColor

对于 iOS 6-,这是视图的背景颜色。对于 iOS 7+,它表示半透明层之上层的背景颜色。

示例

ILTranslucentView_examples

iOS 6 和以下版本?

它工作,但没有透明白色效果。它表现得像一个普通的 UIView。尝试在 backgroundColor 上使用一些不透明度。

Storyboard 或 XIB

在 Identity Inspector 中添加自定义类:ILTranslucentView。

ILTranslucentView_examples