All Projects → lizelu → CEScrollMenue

lizelu / CEScrollMenue

Licence: other
资讯类App中的分类展示、分类切换、分类编辑

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to CEScrollMenue

code-DS-ALGO
👨‍💻 Collection of algorithm and data structure codes, and competitive programming.
Stars: ✭ 31 (+158.33%)
Mutual labels:  coding
yt-channels-DS-AI-ML-CS
A comprehensive list of 180+ YouTube Channels for Data Science, Data Engineering, Machine Learning, Deep learning, Computer Science, programming, software engineering, etc.
Stars: ✭ 1,038 (+8550%)
Mutual labels:  coding
autumn
采用Spring、Spring Boot、Redis、MyBatis、Shiro、Druid框架开发,搭载mysql数据。 如果你厌烦了MyBatis中需要手动创建表的事情,这个项目非常适合你,自动为你生成表。 从此你不在需要导入sql文件了,项目初始化变得异常简单,结构清晰,易于开发,真正拿来可用。 全注解MyBatis开发,没有任何mapper文件,一切sql 映射都用代码实现,全程无xml配置,对xml编写mapper有恐惧症的人的福音。 提供双向生成功能: 实体类自动生成数据库表,全过程不需要任何SQL语句,所有表自动生成 通过表生成基础结构代码,生成代码中已包含CRUD功能,表级别的API接口全部都有 基本实例数据全自动通过代码初始化,无需干预 仅仅只需要修改数据库连接地址,…
Stars: ✭ 28 (+133.33%)
Mutual labels:  coding
the-aviator
🎮 Welcome to the Aviator game!
Stars: ✭ 35 (+191.67%)
Mutual labels:  coding
LeetCode
Competitive coding submissions at Leetcode goes here
Stars: ✭ 14 (+16.67%)
Mutual labels:  coding
Python-Audio-Coder
No description or website provided.
Stars: ✭ 22 (+83.33%)
Mutual labels:  coding
VARBook
程序员的英语助手,输入中文,智能转换为英文变量
Stars: ✭ 24 (+100%)
Mutual labels:  coding
Development
All sort of public guides and information related to mobile development.
Stars: ✭ 15 (+25%)
Mutual labels:  coding
long-doge-challenge
The Long Doge Challenge
Stars: ✭ 18 (+50%)
Mutual labels:  coding
eureka
✍️ I read, I write, I think, I do, I learn, I code.
Stars: ✭ 106 (+783.33%)
Mutual labels:  coding
awesome-learn-by-playing
A collection of tech resources that allow you to learn new things by playing games
Stars: ✭ 95 (+691.67%)
Mutual labels:  coding
Julia
Algorithms implemented in the Julia programming language. We're collaborating with the Humans of Julia community!
Stars: ✭ 216 (+1700%)
Mutual labels:  coding
HALO-SCRIPT-PROJECTS
✅ Halo PC|CE - Add-ons for Phasor V2+ and SAPP 🇳🇿
Stars: ✭ 25 (+108.33%)
Mutual labels:  coding
Gigrator
Git repos migration tool which supports Github / Gitee / Gitlab / Gitea / Coding / Gogs / 腾讯工蜂.
Stars: ✭ 34 (+183.33%)
Mutual labels:  coding
coding-ai
CodingAI is an open source application and it helps to find a mentor related your technologies stack.
Stars: ✭ 60 (+400%)
Mutual labels:  coding
Competitive-Programming-Codes
Includes codes from coding competitions and contests over the internet. Languages:- Python3 and C++
Stars: ✭ 14 (+16.67%)
Mutual labels:  coding
GoGetit
Go学习+面试通关, 覆盖Go程序员需要掌握的所有基础知识
Stars: ✭ 44 (+266.67%)
Mutual labels:  coding
Yet Another Algorithms Repository
Beginner friendly repo for easily contributing algorithms' implementations
Stars: ✭ 31 (+158.33%)
Mutual labels:  coding
Let-Us-Java
[Hacktoberfest 2021] Any amazing 🔥 💯 code you may think of in Java, Let's compile all of them here
Stars: ✭ 39 (+225%)
Mutual labels:  coding
YLib
📖 Kişisel Kütüphanem
Stars: ✭ 19 (+58.33%)
Mutual labels:  coding

CEScrollMenue

上篇博客我们聊了《资讯类App常用分类控件的封装与实现(CollectionView+Swift3.0)》,今天的这篇博客就在上篇博客的基础上做些东西。做一个完整的资讯类App中的分类展示、分类切换、分类编辑这一套东西。当然,主要我们还是使用灵活多变的CollectionView来实现。下方我们将会给出程序的运行效果,然后给出核心的代码实现,在文章的末尾我们会给出github上源代码的分享链接。

一、运行效果展示

下方的GIF动图就是本篇博客所涉及Demo的运行效果了。首先我们点击第一个页面的“Show Menu Scroll”按钮Push到我们的主菜单页面。主菜单页面上方就是我们的菜单选项了,点击相应的菜单项,会显示相应的内容。当然你对下方内容进行滑动,菜单项也会随之改变。

点击菜单右边的加号,Present出菜单的编辑页面,该页面也就是我们上篇博客所介绍的页面。在该页面我们可以添加新的菜单项,并对已经添加的菜单项进行拖动排序。具体效果如下所示。

  

二、工程目录介绍

下方截图中是本篇博客所涉及到 工程目录。本部分将会对下方的目录进行介绍,从而对整个工程进行了解。

  • 1、CEMenuScrollController:CEMenuScrollController控制类就是上面有菜单下方是内容的类,该类是整个实例的主控制器,起到整体的调度作用,负责将各个组件拼接到一块。
  • 2、CEContentConllectionView: 该视图就是下方内容展示的视图,主要是随着菜单的改变而显示不同的内容。
  • 3、CEScrollMenu: 该组件就是上面那个可以横向滚动的菜单了。
  • 4、CESelectTheme: 该组件就是上篇博客所介绍的,负责编辑菜单的组件。 本部分先整体上看一下,下方将会逐步的对每个组件的具体实现进行介绍。

  

三、CEScrollMenu组件的介绍

该组件就是本示例上面横向滚动的菜单项,该组件的右边有一个“+”号按钮,点击该按钮将会通过闭包的形式将按钮的点击事件回调给CEMenuScrollController控制器,由该控制器Present出CESelectTheme组件进行数据源的操作。接下来我们将聊一下CEScrollMenu组件的核心代码。

1、点击Cell的操作

下方是位于CEMenuCollectionView中的代码段,也就是点击菜单对应的Cell时所执行的方法。在该方法中主要做了两件事情,第一件事情是点击的Cell如果可以移动到屏幕的中点。然后将Cell的点击事件回调给CEMenuCollectionView的使用者,在回调时,要传入当前点击Cell的indexPath。

  

2、计算菜单Cell的宽度

下方代码段是CEMenuCollectionView中设置Cell尺寸的布局回调。Cell的宽度是从我们的数据源中获取的,我们的Model中有一个itemWidth()方法用来提供显示该item的Cell的宽度。当然该宽度是根据我们菜单名字的个数来获取的。

  

3、点击菜单项将其置为选择状态

下方代码是CEMenuCollectionViewCell中负责根据Cell的Select状态来修改Cell的显示方案的,具体代码如下所示。当然,Cell是否处于Select状态,我们将此状态是记录在我们的Model中的,这就避免了因为Cell的重用机制而出现的状态不一致的问题。

下方代码就是CEMenuCollectionViewCell初始化时所进行的处理。从下方我们可以看出Cell的isSelected状态是从item中加载的,加载后,调用上述updateStelectState()方法。具体做法如下所示:

  

关于CEScrollMenu组件的介绍,本篇博客就先介绍这么多,更详细的代码请移步于文章后方的github地址。

四、CEContentCollectionView的介绍

CEContentCollectionView的主要功能是根据Menu的切换来显示相应的内容的,该视图中的内容比较简单。下方是对其核心技术点的介绍。

1、确定用户左右滑动后当前显示的页面

下方三个代理方法是用来确定用户左右滑动内容页后,所显示的Cell。当用户拖动后切换了相应的Cell时,会执行下方的的currentShowCellClosure()闭包,然后将当前显示Cell的indexPath回调给使用者。然后我们可以根据该IndexPath改变Menu当前显示的菜单项。

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].