• <legend id='n7J30'><style id='n7J30'><dir id='n7J30'><q id='n7J30'></q></dir></style></legend>

        <tfoot id='n7J30'></tfoot>

        <small id='n7J30'></small><noframes id='n7J30'>

        <i id='n7J30'><tr id='n7J30'><dt id='n7J30'><q id='n7J30'><span id='n7J30'><b id='n7J30'><form id='n7J30'><ins id='n7J30'></ins><ul id='n7J30'></ul><sub id='n7J30'></sub></form><legend id='n7J30'></legend><bdo id='n7J30'><pre id='n7J30'><center id='n7J30'></center></pre></bdo></b><th id='n7J30'></th></span></q></dt></tr></i><div id='n7J30'><tfoot id='n7J30'></tfoot><dl id='n7J30'><fieldset id='n7J30'></fieldset></dl></div>
        • <bdo id='n7J30'></bdo><ul id='n7J30'></ul>

        使用 Swift 对 ImageView 的 iOS 模糊效果

        时间:2024-04-15

      1. <small id='R9d64'></small><noframes id='R9d64'>

      2. <legend id='R9d64'><style id='R9d64'><dir id='R9d64'><q id='R9d64'></q></dir></style></legend>
        • <bdo id='R9d64'></bdo><ul id='R9d64'></ul>

              <i id='R9d64'><tr id='R9d64'><dt id='R9d64'><q id='R9d64'><span id='R9d64'><b id='R9d64'><form id='R9d64'><ins id='R9d64'></ins><ul id='R9d64'></ul><sub id='R9d64'></sub></form><legend id='R9d64'></legend><bdo id='R9d64'><pre id='R9d64'><center id='R9d64'></center></pre></bdo></b><th id='R9d64'></th></span></q></dt></tr></i><div id='R9d64'><tfoot id='R9d64'></tfoot><dl id='R9d64'><fieldset id='R9d64'></fieldset></dl></div>
                <tbody id='R9d64'></tbody>

                <tfoot id='R9d64'></tfoot>

                  本文介绍了使用 Swift 对 ImageView 的 iOS 模糊效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试制作简单的 iOS 应用程序.我需要制作具有模糊效果的图像视图.我在 Stack Overflow 上找到了这段代码:

                  I am trying to make simple iOS app. I need to make image view with blur effect. I found this code on Stack Overflow:

                  class BlurImageView: UIImageView {
                  
                    override func awakeFromNib() {
                      super.awakeFromNib()
                    }
                  
                    required init(coder aDecoder: NSCoder!){
                        super.init(coder: aDecoder)   
                        var blur:UIBlurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
                        var effectView:UIVisualEffectView = UIVisualEffectView (effect: blur)
                        effectView.frame = frame
                        addSubview(effectView)
                    }
                  }
                  

                  我需要将这个类连接到我的 image_view,但我不知道该怎么做.我尝试在 ViewControllerview_did_load 函数中执行此操作(image_view 是一个出口)

                  And I need to connect this class to my image_view, but I don't know how to do it. I try to do it in my view_did_load function in my ViewController (image_view is a outlet)

                  override func viewDidLoad() {
                      super.viewDidLoad()
                      image_view = BlurImageView()
                  }
                  

                  但是 NSCoder 是必需的……它是什么?也许我的方式是错误的方式?

                  but NSCoder required... What is it? maybe my way is a wrong way?

                  推荐答案

                  你需要让你的 image_view 成为 BlurImageView 的一个实例,所以在你的视图控制器和你的image_view 是一个 outlet,你需要让它成为 BlurImageView 的实例,而不是 UIImageView 的实例.

                  You need to make your image_view an instance of BlurImageView, so in your view controller and where your image_view is an outlet, you need to make it an instance of BlurImageView and not an instance of an UIImageView.

                  这篇关于使用 Swift 对 ImageView 的 iOS 模糊效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 iPhone 中显示图库中的图像 下一篇:iOS 显示 tableview 标题图片(视差效果)

                  相关文章

                  <i id='7Ug6l'><tr id='7Ug6l'><dt id='7Ug6l'><q id='7Ug6l'><span id='7Ug6l'><b id='7Ug6l'><form id='7Ug6l'><ins id='7Ug6l'></ins><ul id='7Ug6l'></ul><sub id='7Ug6l'></sub></form><legend id='7Ug6l'></legend><bdo id='7Ug6l'><pre id='7Ug6l'><center id='7Ug6l'></center></pre></bdo></b><th id='7Ug6l'></th></span></q></dt></tr></i><div id='7Ug6l'><tfoot id='7Ug6l'></tfoot><dl id='7Ug6l'><fieldset id='7Ug6l'></fieldset></dl></div>

                      <bdo id='7Ug6l'></bdo><ul id='7Ug6l'></ul>

                    <small id='7Ug6l'></small><noframes id='7Ug6l'>

                  1. <legend id='7Ug6l'><style id='7Ug6l'><dir id='7Ug6l'><q id='7Ug6l'></q></dir></style></legend>
                    <tfoot id='7Ug6l'></tfoot>