0
我正在调试从Objective-C转换而来的下拉菜单。在这里面,我有这样的功能:无法使用alpha属性调用非函数类型'CGFloat'的值
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
。什么会导致这个错误?
让我现在如果你需要更多的信息。
你应该把它像'self.container.alpha = containerAlpha',因为'alpha'是一个属性,你应该分配给它 –
@DánielNagy 。谢谢,它工作。你为什么在评论中回答这个问题? –
我不是100%确定,但我很高兴它的工作 –