无法使用alpha属性调用非功能类型'CGFloat'的值 [英] Cannot call value of non-function type 'CGFloat' with the alpha property

查看:233
本文介绍了无法使用alpha属性调用非功能类型'CGFloat'的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调试从Objective-C转换的下拉菜单.在其中,我具有以下功能:

I am debugging a dropdown menu I converted from Objective-C. In it, I have this function:

func showMenu() {
        self.menu.hidden = false
        self.menu.translatesAutoresizingMaskIntoConstraints = true

        closedMenuShape.removeFromSuperlayer()

        if shouldDisplayDropShape {
            self.view.layer.addSublayer(openMenuShape)
        }

        // Set new origin of menu
        var menuFrame: CGRect = self.menu.frame
        menuFrame.origin.y = self.menubar.frame.size.height - self.offset()


        var containerAlpha: CGFloat = fadeAlpha

        if SYSTEM_VERSION_LESS_THAN("7.0") {
            UIView.beginAnimations(nil, context: nil)
            UIView.setAnimationCurve(.EaseInOut)
            self.menu.frame = menuFrame
            self.container.alpha(containerAlpha) <======= Error
        }
        else {
            UIView.animateWithDuration(0.4,
                                delay: 0.0,
               usingSpringWithDamping: 1.0,
                initialSpringVelocity: 4.0,
                              options: .CurveEaseInOut,
                           animations: {
                                self.menu.frame = menuFrame
                                self.container.alpha(containerAlpha) <==== Error

                }, completion: {(finished: Bool) in
             })
           }

        UIView.commitAnimations()

    }

在其中我已标记出错误正在显示,在行上是self.container.alpha(containerAlpha).错误显示Cannot call value of non-function type 'CGFloat',这是容器的声明:

In there I have marked were the error is showing up, on the lines were self.container.alpha(containerAlpha) is. The error says Cannot call value of non-function type 'CGFloat', and this is the declaration for container:

@IBOutlet weak var container: UIImageView!

我已经导入了UIKit.是什么导致此错误?

I have imported UIKit. What would be causing this error?

如果您需要更多信息,请让我现在.

Let me now if you need more information.

推荐答案

由于UIImageView具有alpha属性(不是方法),因此需要将alpha值分配给UIImageView,如下所示:

Since a UIImageView has an alpha property (not a method), you need to assign the alpha value to the UIImageView, like this:

 self.container.alpha = containerAlpha

另一方面;如果UIImageView did 使用alpha方法,则应使用

On the other hand; if UIImageView did have an alpha method, you would use

self.container.alpha(containerAlpha)

这篇关于无法使用alpha属性调用非功能类型'CGFloat'的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆