【问题标题】:How to create opaque background like in the bottom panel in Swift?如何在 Swift 的底部面板中创建不透明的背景?
【发布时间】:2015-09-20 19:33:55
【问题描述】:

我想用 iOS7-8 的底部面板中的背景颜色创建标签,如下所示:

或者创建一个视图并在其中放置标签。我怎样才能达到这个结果?

【问题讨论】:

    标签: ios swift xcode6 background-color


    【解决方案1】:

    你可以使用模糊效果

    例如

        let blurEffect =  UIBlurEffect(style: UIBlurEffectStyle.Light)
        let bluredEffectView = UIVisualEffectView(effect: blurEffect)
        bluredEffectView.frame = CGRectMake(100, 100, 200, 200)
        self.imageview.addSubview(bluredEffectView)
    

    截图

    【讨论】:

    • 谢谢!如何使不透明度约为 0.8?我可以吗?
    • 使用UIVisualEffectView时不能设置alpha。可以设置UIBlurEffect 的风格,有3种:light,extraLight,dark
    猜你喜欢
    • 2018-05-30
    • 1970-01-01
    • 2017-10-13
    • 2020-09-22
    • 1970-01-01
    • 2017-02-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-04
    相关资源
    最近更新 更多