实现类似QQ的折叠效果
// 实现类似QQ的折叠效果
//
// Created by skg_Myfly on 16/3/3.
// Copyright © 2016年 skg_Myfly. All rights reserved.
//
#import "ViewController.h"
#import "QQCellModel.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
/** tableview */
@property (nonatomic , strong ) UITableView *tableView;
/** 全局数据源 */
@property (nonatomic , strong ) NSMutableArray *dateArray;
@end
if (!_dateArray) {
self.dateArray = [NSMutableArray array];
}
return _dateArray;
}
- (void)viewDidLoad {
QQCellModel* model = [[QQCellModel alloc] init];
model.name = [NSString stringWithFormat:@"%c",i];
// model.isShow = YES;
for (int j = 0; j < 10; j ++) {
[model.array addObject: [NSString stringWithFormat:@"%c - %d",i,j]];
}
[self.dateArray addObject:model];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.rowHeight = 50;
[self.view addSubview:_tableView];
}
return [_dateArray count];
}
QQCellModel* model = [_dateArray objectAtIndex:section];
if (model.isShow) {
return model.array.count;
}else{
return 0;
}
static NSString* ID = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID ];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
}
QQCellModel* model = [_dateArray objectAtIndex:indexPath.section];
NSString* str = [[model array] objectAtIndex:indexPath.row];
cell.textLabel.text = str;
return cell;
}
QQCellModel* model = [_dateArray objectAtIndex:section];
UIButton* btn =[UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 50);
[btn setTitle:model.name forState:UIControlStateNormal];
btn.tag = section;
[btn addTarget:self action:@selector(btnClick:with:) forControlEvents:UIControlEventTouchUpInside];
if (section % 2) {
btn.backgroundColor = [UIColor darkGrayColor];
}else{
btn.backgroundColor = [UIColor lightGrayColor];
}
return btn;
}
QQCellModel* model = [_dateArray objectAtIndex:btn.tag];
if ([model isShow]) {
[model setIsShow:NO];
}else{
[model setIsShow:YES];
}
[_tableView reloadSections:[NSIndexSet indexSetWithIndex:btn.tag] withRowAnimation:UITableViewRowAnimationFade];
// [_tableView reloadRowsAtIndexPaths:<#(nonnull NSArray<NSIndexPath *> *)#> withRowAnimation:<#(UITableViewRowAnimation)#>]
}
// QQCellModel.h
// 实现类似QQ的折叠效果
//
// Created by skg_Myfly on 16/3/3.
// Copyright © 2016年 skg_Myfly. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface QQCellModel : NSObject
/**名字 */
@property (nonatomic ,copy ) NSString* name;
/**是否展开 */
@property (nonatomic , assign ) BOOL isShow;
/** 每组的数据 */
@property (nonatomic , strong ) NSMutableArray *array;
实现类似QQ的折叠效果的更多相关文章
- js仿qq分组折叠效果
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- 使用plupload做一个类似qq邮箱附件上传的效果
公司项目中使用的框架是springmvc+hibernate+spring,目前需要做一个类似qq邮箱附件上传的功能,暂时只是上传小类型的附件 处理过程和解决方案都需要添加附件,处理过程和解决方案都可 ...
- WinForm实现类似QQ停靠,显示隐藏过程添加特效效果
原文:WinForm实现类似QQ停靠,显示隐藏过程添加特效效果 这可能是个老题长谈的问题了,只是在项目中会用到这个效果,所以今天做个记录.大家见了别喷我.在项目中的需求是这样的. 打开程序,在屏幕的右 ...
- winform-实现类似QQ停靠桌面上边缘隐藏的效果
//实现类似QQ停靠桌面上边缘隐藏的效果! private void timer1_Tick(object sender, EventArgs e) { System.Drawing.Point pp ...
- css3折叠效果
在开发过程中,经常会遇到一些交互效果,今天所联系的便是一个类似折纸的折叠效果,查看效果. 说到折纸,我们先看下图 这是我第一时间想到的大体思路,如果能让这6个面连续的变化角度到0不就可以了吗,运用cs ...
- MVC实现类似QQ的网页聊天功能-ajax(下)
此篇文章主要是对MVC实现类似QQ的网页聊天功能(上)的部分代码的解释. 首先说一下显示框的滚动条置底的问题: 结构很简单一个大的div(高度一定.overflow:auto)包含着两个小的div第一 ...
- 创意HTML5文字特效 类似翻页的效果
原文:创意HTML5文字特效 类似翻页的效果 之前在网上看到一款比较有新意的HTML5文字特效,文字效果是当鼠标滑过是出现翻开折叠的效果,类似书本翻页.于是我兴致勃勃的点开源码看了一下,发现其实实现也 ...
- .net winForm 实现类似qq 弹出新闻
.net winForm 实现类似qq 弹出新闻 一.背景: echong 之前一直用 公司大牛c语言写的一个弹出托管,前几天写东西的时候发现com调用不是那么好使.而手头上写的这个东西又是.ne ...
- 用C#代码实现类似QQ窗体的“上、左、右”停靠功能
大家都知道QQ有一个自动停靠功能,即“上.左.右”,当你把窗体拖到屏幕边缘,然后移开鼠标它会自动缩放,然后只显示一小小点出来,我们仔细观察会发现其实它只露3像素左右的边缘,当你鼠标移上去它又会伸出来, ...
随机推荐
- 数据(数组,json)的处理
有些时候我们在做联动事件以及获取动态的数据是,给到我们的都是数组,json格式的数据. 为了方便快速的处理这些数据,jq给我们提供了很多简便的方法. each()方法 在jQuery里有一个each方 ...
- 使用 HTML5 设计辅助功能
使用 HTML5 设计辅助功能 Rajesh Lal 下载代码示例 如果您真的对面向广大受众感兴趣,将需要为网站设计辅助功能. 辅助功能使网页更易于访问.更易于使用,可供每个人浏览. 通常,使用最新的 ...
- 基于jquery的页面预载入效果(loading)
css代码: <style> #loading{ position:absolute; width:300px; top:0px; left:50%; margin-left:-150px ...
- [kuangbin带你飞]专题十 匹配问题 二分图最大权匹配
二分图最大权匹配有km算法和网络流算法 km算法模板默认解决最大权匹配的问题 而使用最小费用最大流 是解决最小权匹配问题 这两种办法都可以求最大最小权 需要两次取反 TAT 感觉讲km会很难的样子.. ...
- 转:15 Best Responsive Web Design Testing Tools
Responsive Web Design is regarded as being the approach which suggests that web design and developme ...
- 转:ASCII码表_全_完整版
ASCII码表 ASCII值 控制字符 ASCII值 控制字符 ASCII值 控制字符 ASCII值 控制字符 0 NUL 32 (space) 64 @ 96 . 1 SOH 33 ! 65 A 9 ...
- linux系统ecshop拿shell方法
Title:linux系统ecshop拿shell方法 --2011-06-08 13:23 最近弄一个站,对ECSHOP拿shell不了解,导致走了很多的弯路. nginx/0.8.54的服务器, ...
- SQLiteDatabase中的事务
beginTransaction():开始事务endTransaction():结束事务SQLiteDatabase还提供了如下方法来判断当前上下文是否处于事物环境中.inTransaction(): ...
- AcitonBar 自定义布局
Android系统中ActionBar默认的布局不美观且难于控制,通过为ActionBar自定义布局的方式可以灵活控制ActionBar. 自定义Activity主题和ActionBar样式 在新建的 ...
- HDOJ 1266 Reverse Number(数字反向输出题)
Problem Description Welcome to 2006'4 computer college programming contest! Specially, I give my bes ...