【问题标题】:How to make a UIBlurEffect that works on IPAD 3如何制作适用于 IPAD 3 的 UIBlurEffect
【发布时间】:2016-06-03 23:23:33
【问题描述】:

我正在使用 IPAD 3 (MD368TY/A) 作为测试硬件为 iOS 开发软件。我正在尝试在背景图像上创建模糊效果,但我得到了这个结果:

“正确”应该是:

(使用iPhone 5S模拟器得出的结果)

我的代码是:

import UIKit

class ProfileMgmtViewController: UIViewController {

  @IBOutlet weak var bgImageContainerView: UIView!
  @IBOutlet weak var userBgImg: UIImageView!
  @IBOutlet weak var userImg: UIImageView!

  override func viewDidLoad() {
    ...

    userBgImg.backgroundColor = UIColor(patternImage: userImg.image!)

    let blurEffect = UIBlurEffect(style: .Light)
    let blurView  = UIVisualEffectView(effect: blurEffect)
    blurView.frame = userBgImg.bounds
    print (userBgImg.bounds)
    userBgImg.addSubview(blurView)
    ...

我读到这个版本的 IPAD 不支持模糊效果。真的吗?有什么方法可以让模糊效果在这里起作用吗?

【问题讨论】:

    标签: ios swift ipad


    【解决方案1】:

    没错,来自这次 WWDC 会议:http://asciiwwdc.com/2014/sessions/419

    所以,重申一下我们不会模糊哪些设备,我们只会做 iPad 2 和 iPad 第 3 代上的着色,我们只需应用 着色,我们跳过模糊步骤。

    在 iPad 第 4 代、iPad Air、iPad Mini、iPad Mini with Retina 显示器、iPhone 和 iPod touch,我们同时进行模糊和 着色。

    模糊效果非常昂贵,因此 UI 可以轻松绑定 GPU,因此,在早期版本的 iPad 或 iPhone 上禁用了模糊效果。据我所知,这里没有办法使模糊效果起作用。

    或者,您可以detect if a device support Blur effect 并做相应的事情。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多