详情页,tableview的headview,下拉图片放大
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let offsetY = scrollView.contentOffset.y
if offsetY < 0 {
let totalOffset = tableView.tableHeaderView?.frame.height + abs(offsetY)
let f = totalOffset / tableView.tableHeaderView?.frame.height
headerView.bgImageView.frame = CGRect(x: -UIScreen.main.bounds.width * (f - 1) * 0.5, y: offsetY, width: UIScreen.main.bounds.width * f, height: totalOffset)
}
}
网友评论