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()
}
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!
I have imported UIKit
. What would be causing this error?
Let me now if you need more information.
Since a
UIImageView
has an alpha property (not a method), you need to assign the alpha value to theUIImageView
, like this:On the other hand; if
UIImageView
did have an alpha method, you would use