美文网首页
iOS push出present类似的模态效果

iOS push出present类似的模态效果

作者: 可乐小子 | 来源:发表于2024-02-26 14:35 被阅读0次

    func popVcCustomAnimation(_ viewController: UIViewController? = nil) {
    let vc = viewController == nil ? self:viewController
    let animation = CATransition()
    animation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
    animation.type = .fade
    animation.duration = 0.3
    vc?.navigationController?.view.layer.add(animation, forKey: nil)
    vc?.navigationController?.popViewController(animated: false)
    }

    func popRootVcCustomAnimation(_ viewController: UIViewController? = nil) {
        let vc = viewController == nil ? self:viewController
        let animation = CATransition()
        animation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
        animation.type = .fade
        animation.duration = 0.3
        vc?.navigationController?.view.layer.add(animation, forKey: nil)
        vc?.navigationController?.popToRootViewController(animated: false)
    }
    
    func pushVcCustomAnimation(_ viewController: UIViewController) {
        navigationController?.pushViewController(viewController, animated: false)
        let animation = CATransition()
        animation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
        animation.type = .fade
        animation.duration = 0.3
        navigationController?.view.layer.add(animation, forKey: nil)
    }

    相关文章

      网友评论

          本文标题:iOS push出present类似的模态效果

          本文链接:https://www.haomeiwen.com/subject/upniadtx.html