上一篇这里,写了和UIAlertController
有关的弹出视图,但是在实际情况中,我发现其他各大应用的弹出的视图都是没有带弧度的那一种,从设计理念来说,UIAlertController
的方式会显得比较突兀不太友好。所以这里分享的是另外一种与UIAlertController
无关的视图
- 支持一行动态显示
- 支持两行动态显示
- 不支持滑屏(一般的分享想必也不会有超过8个的)
弹出动画:
buttonY += kScreenHeight
customButton.frame = CGRect(x: buttonX, y: buttonY, width: CGFloat(buttonWeight), height: CGFloat(buttonHeight))
customButton.alpha = 0
DispatchQueue.main.asyncAfter(deadline: .now() + 0.03 * Double(i), execute: {
UIView.animate(withDuration: 0.35, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0.8, options: .curveEaseIn, animations: {
customButton.alpha = 1
customButton.frame = CGRect(x: buttonX, y: buttonY - kScreenHeight, width: CGFloat(buttonWeight), height: CGFloat(buttonHeight))
}, completion: nil)
})
点击按钮时显示的动画:
func menuBtnTouchUpInside(_ button: UIButton){
button.imageView?.clipsToBounds = false
for customButton in self.meunButtons {
customButton.titleLabel?.alpha = 0
UIView.animate(withDuration: 0.3, animations: {
customButton.alpha = 0
if customButton.isEqual(button){
customButton.imageView?.transform = CGAffineTransform(scaleX: 3, y: 3)
}else{
customButton.imageView?.transform = CGAffineTransform(scaleX: 0.3, y: 0.3)
}
}, completion: { (bool ) in
})
}
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
self.meunButtons.removeAll()
self.bottomBtnDidClick(button)
}
if delegate != nil {
self.delegate?.didClickOnItemAtIndex(index: button.tag)
}
}
完整代码在这里!