Skip to content

转场过程中图片过度, 过渡之后tableView下拉图片放大

License

Notifications You must be signed in to change notification settings

AngryOC/custiomImageTransitionAnimation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

custiomImageTransitionAnimation

转场过程中图片过度, 过渡之后tableView下拉图片放大

转场动画
//核心是线面这个类
class ImageTransition: NSObject, UIViewControllerAnimatedTransitioning

// 转场的from 和 to viewcontroller 都需要遵循的协议
 protocol ImageTransitionCDelegate: class{
    func willTransitionPrepareInfo()->(UIImageView?, String?)
}

//demo: 中 fromvc -> ListController
//         toVC ->  DetailController

//ListController.swift
//提供fromvc 需要过度的动画控件 和 图片URL
func willTransitionPrepareInfo()->(UIImageView?, String?){
    if let selectRow = tableView.indexPathForSelectedRow  {
        if let cell = tableView.cellForRow(at: selectRow) as? ListCell{
            return (cell.imageV, cell.model)
        }
    }
    return (nil, nil)
}

//DetailController.swift
// 提供 动画控件 目标位置
func willTransitionPrepareInfo()->(UIImageView?, String?){
        return (topImageView, nil)
    }
图片 下拉放
//DetailController.swift
 func scrollViewDidScroll(_ scrollView: UIScrollView) {
    debugPrint(scrollView.contentOffset)
    if scrollView.contentOffset.y <  -imageHeight {
        let tmpWidth = UIScreen.main.bounds.width*(-scrollView.contentOffset.y)/imageHeight
        topImageView.frame = CGRect(origin: CGPoint(x: -(tmpWidth-UIScreen.main.bounds.width)/2.0, y: 0), size: CGSize(width: tmpWidth, height: -scrollView.contentOffset.y))
    } else {
        topImageView.frame = CGRect(origin: .zero, size: CGSize(width: UIScreen.main.bounds.width, height: imageHeight))
    }
}

1 From ViewController

2 to ViewController

3. gif

效果视频

About

转场过程中图片过度, 过渡之后tableView下拉图片放大

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages