Code Monkey home page Code Monkey logo

redbookheaderscrolldemo's Introduction

RedBook Header Scroll Demo

仿小红书顶部详情图片高度可变空间

Swift4 Available

Swift练手项目..项目可能存在很多不足..效果如下图所示..

参考大佬思路实现-> :大佬Demo传送门

小红书App中效果:

Demo效果:

控件添加了可用于下拉刷新情景的重新加载,定位到刷新前位置功能

Usage

Step1. 生成图片Model

//image为图片数据
let imageModel = pictureScrollImageModel.init(generateImageModel: image)

Step2. 将图片存进数组赋值给控件

初始化控件:

//需要设置控件初始宽度
//设置控件宽度为 屏幕宽度
viewPager = PictureScrollView.init(frame: CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: 0))
//设置控件代理
//控件代理用于,滑动时候,根据回调控件高度,在外面调整控件Frame
viewPager.delegate = self

设置数据源

//将存有Model数组赋值给控件
viewPager.imageSource = imageSourceArrary

赋值完之后需要Reload数据

//赋值完之后需要Reload,重新布局
//同理,如果存在下拉刷新更新数据源,也需要手动调用Reload
viewPager.reload()

Step3 . 设置代理

//根据控件计算的高度,时刻调整控件在父类的Frame
func pictureScrollViewDidScroll(_ pictureScrollView: PictureScrollView, contentOffset: CGPoint, pictureScrollViewSuitHeight: CGFloat) {
        viewPager.frame = CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: viewPager.pictureScrollViewHeight)
    }

)

控件添加了可用于下拉刷新情景的重新加载,定位到刷新前位置功能

Usage

Step1. 生成图片Model

//image为图片数据
let imageModel = pictureScrollImageModel.init(generateImageModel: image)

Step2. 将图片存进数组赋值给控件

初始化控件:

//需要设置控件初始宽度
//设置控件宽度为 屏幕宽度
viewPager = PictureScrollView.init(frame: CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: 0))
//设置控件代理
//控件代理用于,滑动时候,根据回调控件高度,在外面调整控件Frame
viewPager.delegate = self

设置数据源

//将存有Model数组赋值给控件
viewPager.imageSource = imageSourceArrary

赋值完之后需要Reload数据

//赋值完之后需要Reload,重新布局
//同理,如果存在下拉刷新更新数据源,也需要手动调用Reload
viewPager.reload()

Step3 . 设置代理

//根据控件计算的高度,时刻调整控件在父类的Frame
func pictureScrollViewDidScroll(_ pictureScrollView: PictureScrollView, contentOffset: CGPoint, pictureScrollViewSuitHeight: CGFloat) {
        viewPager.frame = CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: viewPager.pictureScrollViewHeight)
    }

redbookheaderscrolldemo's People

Contributors

swlfigo avatar imgbotapp avatar

Stargazers

SuperX avatar LinkJin avatar  avatar  avatar qianyu avatar  avatar SillyLong avatar echo avatar  avatar 许孝泳 avatar Louis avatar

Watchers

James Cloos avatar  avatar

redbookheaderscrolldemo's Issues

不错

小伙子是不是借鉴了我的Demo,如果是,我感到很荣幸

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.