今天开通了自己的第一的csdn博客,写第一篇文章吧。
我是个iOS菜鸟,今天刚刚考试完,心情大好,前阵子玩百度贴吧的iPhone客户端,发现它里面的列表加载效果挺好的,于是自己做了一个,效果可能不是特别像吧,不知道思路对不对。
这里是核心代码实现,大家应该都知道iOS里面单元格的复用机制,不知道的可以去查一下资料。实现的思路就是在代理方法中先把cell的透明度和frame进行修改,然后再利用UIView的动画复原,就有了动态加载的效果;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
static NSString *identify = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identify];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identify];
[cell setBackgroundColor:[UIColor purpleColor]];
}
//cell.frame.size.height *=10;
CGRect frame = cell.frame;
CGRect or_frame = frame;
frame.size.height += 80;
frame.origin.y += 1000;
[cell setFrame:frame];
[cell setAlpha:0.1];
[cell.textLabel setText:identify];
[UIView animateWithDuration:1 animations:^{
[cell setAlpha:1.0f];
[cell setFrame:or_frame];
}];
return cell;
}
工程文件下载地址:http://pan.baidu.com/s/1kThY0j9
如果大家有什么更好的思路欢迎大家提出来,共同进步。