无法使用 alpha 属性 调用非函数类型 'CGFloat' 的值

Cannot call value of non-function type 'CGFloat' with the alpha property

我正在调试从 Objective-C 转换而来的下拉菜单。在里面,我有这个功能:

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',这是容器的声明:

@IBOutlet weak var container: UIImageView!

我已经导入了UIKit。什么会导致此错误?

如果您需要更多信息,请联系我。

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

 self.container.alpha = containerAlpha

另一方面;如果 UIImageView did 有 alpha 方法,您将使用

self.container.alpha(containerAlpha)