实现类似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像素左右的边缘,当你鼠标移上去它又会伸出来, ...
随机推荐
- CentOS5.5下安装Ant
从yum源直接下ant: [root@master local]$ yum install ant 运行ant,发现报错: java.lang.NoClassDefFoundError: org/ap ...
- phpmyadmin密码字段加密方法
UPDATE member SET password=md5('password')
- C程序设计语言练习题1-14
练习1-14 编写一个程序,打印输入中各个字符出现频度的直方图. 代码如下: #include <stdio.h> // 包含标准库的信息. int main() // 定义名为main的 ...
- MySQL 插入数据时,中文乱码???问题的解决
在终端,mysql -u root -p 登录: show variables like 'character%'; 来查看当前数据库的相关编码集. client 为客户端使用的字符集. connec ...
- 【学习笔记】【oc】copy与mutableCopy
copy 返回一个不可变的对象: mutableCopy 返回一个可变的对象: 使用copy方法时 类必须实现:<NSCopying>协议中的-(id)copyWithZone:(NSZo ...
- ViewPager+Fragment的结合使用,实现QQ界面的理解
http://www.cssxt.com/html/2449/2449.html 效果如图: 实现代码解析:MainActivity.java1.引入布局文件2.4个标题控件的初始化以及点击事件的监听 ...
- android 写文件权限
首先,在manifest.xml中添加user permission:<uses-permission android:name="android.permission.WRITE_E ...
- php preg_match 和preg_match_all
$h3=trim('[我要变强][主流程]整体功能测试点');$matches=array();preg_match_all('/[(.+?)]/', $h3,$matches); print_r($ ...
- Linux 安装字体
把XP下的字体C:\WINDOWS\FONTS\simsun.ttc(也就是宋体,大小为10M),把他重命名为 simsun.ttf 拷贝simsun.ttf 字体到 /usr/share/fonts ...
- 让PV10000+的秘诀
原文地址:http://www.phonegap100.com/article-410-1.html 让PV10000+的秘诀 2015-5-4 21:49| 发布者: admin| 查看: 122| ...