iOS 視圖切換:DAExpandAnimation

jopen 9年前發布 | 10K 次閱讀 iOS開發 移動開發 DAExpandAnimation

DAExpandAnimation 是一個自定義的模式切換,提供一個有拉伸效果的控件。

Usage

Try the example project!

Have your view controller conform to UIViewControllerTransitioningDelegate. Optionally set thecollapsedViewFrame, theexpandedViewFrameand theanimationDuration.

private let animationController = DAExpandAnimation()

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if let toViewController = segue.destinationViewController as? UIViewController, selectedCell = sender as? UITableViewCell {
        toViewController.transitioningDelegate = self
        toViewController.modalPresentationStyle = .Custom
        toViewController.view.backgroundColor = selectedCell.backgroundColor

        animationController.collapsedViewFrame = {
            return selectedCell.frame
        }
        animationController.animationDuration = Constants.SomeAnimationDuration

        if let indexPath = tableView.indexPathForCell(selectedCell) {
            tableView.deselectRowAtIndexPath(indexPath, animated: false)
        }
    }
}

func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    return animationController
}

func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    return animationController
}

截圖

iOS 視圖切換:DAExpandAnimation

項目主頁:http://www.baiduhome.net/lib/view/home/1441786766258

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!