我有这个功能:
Dim lastrow As Long
Dim i As Integer
lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row + 1
i = 4
calc = "=SUM(SUMIF($K$3:$K$19,N3,$L$3:$L$19),"
Do Until i = lastrow
calc = calc & "SUMIF($K$3:$K$19,N" & i & ",$L$3:$L$19),"
i = i + 1
Loop
ActiveSheet.Range("N" & lastrow + 1 & ":BI" & lastrow + 1).Value = calc & ")"
我有一个显示和隐藏视图的功能。我想添加一个动画来显示/隐藏此视图。怎么做?动画的方向是从上到下。
有谁知道怎么做?
答案 0 :(得分:2)
确保设置filterView.clipsToBounds = true
。
func showwAndHideFilterMenu(category : Int) {
if showFilterMenu == false {
var filterFrame = filterView.frame
let actualHeight = filterFrame.size.height
//initially set height to zero and in animation block we need to set its actual height.
filterFrame.size.height = 0
filterView.frame = frame
UIView.animate(withDuration: 0.6, delay: 0, options: .curveEaseInOut, animations: {
self.filterView.isHidden = false
self.showFilterMenu = true
//setting the actual height with animation
filterFrame.size.height = actualHeight
filterView.frame = filterFrame
}) { (isCompleted) in
}
} else {
var filterFrame = filterView.frame
UIView.animate(withDuration: 0.6, delay: 0, options: .curveEaseInOut, animations: {
self.filterView.isHidden = true
self.showFilterMenu = false
//set the height of the filter view to 0
filterView.frame = filterFrame
filterFrame.size.height = 0
filterView.frame = frame
}) { (isCompleted) in
}
}
}
答案 1 :(得分:1)
您需要操纵alpha属性,而不是UIView淡入淡出动画的isHidden属性。
尝试以下方法:
func showAndHideFilterMenu(category : Int) {
if showFilterMenu == false {
self.filterView.alpha = 0.0
self.filterView.isHidden = false
self.showFilterMenu = true
UIView.animate(withDuration: 0.6, delay: 0, options: .curveEaseInOut, animations: {
self.filterView.alpha = 1.0
}) { (isCompleted) in
}
} else{
UIView.animate(withDuration: 0.6, delay: 0, options: .curveEaseInOut, animations: {
self.filterView.alpha = 0.0
}) { (isCompleted) in
self.filterView.isHidden = true
self.self.showFilterMenu = false
}
}
}
答案 2 :(得分:1)
尝试此操作会使您的视图从上到下滑动,然后隐藏该视图
//MARK: Slide View - Top To Bottom
func viewSlideInFromTopToBottom(view: UIView) -> Void {
let transition:CATransition = CATransition()
transition.duration = 0.5
transition.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
transition.type = CATransitionType.push
transition.subtype = CATransitionSubtype.fromBottom
view.layer.add(transition, forKey: kCATransition)
}
<强>用法强>
// Cancel Button
@IBAction func cancelButtonAction(_ sender: Any) {
self.viewSlideInFromTopToBottom(view: hideAndShowPickerView)
hideAndShowPickerView.isHidden = true
}