项目介绍:
自定义类:YLMoveImageView.swift,实则是继承UIView,添加一个子视图UIImageView。
使用方法:
生成:
{ self.m_moveImage = YLMoveImageView.init(frame: CGRect.init(x: 0, y: self.view.frame.maxY*0.7, width: self.view.frame.width, height: 150))
self.m_moveImage!.imageDefault = UIImage.init(named: "dog.jpeg") self.m_moveImage!.image_url = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1536213492635&di=e4024ce8aa1b0ae90ca5c4e649d57fca&imgtype=0&src=http%3A%2F%2Fimg17.3lian.com%2Fd%2Ffile%2F201702%2F08%2F4972db13f75df2df2446259945029d0d.jpg"}
scrollViewDidScroll 方法中:func scrollViewDidScroll(_ scrollView: UIScrollView) {
self.m_moveImage!.image_offset = scrollView.contentOffset.y
}