UITableViewCell状态切换效果

简介:

UITableViewCell状态切换效果

 

效果图

 

源码

https://github.com/YouXianMing/Animations


//
//  TableViewTapAnimationController.m
//  Animations
//
//  Created by YouXianMing on 15/11/27.
//  Copyright © 2015年 YouXianMing. All rights reserved.
//

#import "TableViewTapAnimationController.h"
#import "TableViewTapAnimationCell.h"
#import "UIView+SetRect.h"
#import "TapAnimationModel.h"

@interface TableViewTapAnimationController () <UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) UITableView   *tableView;
@property (nonatomic, strong) NSArray       *dataArray;

@end

@implementation TableViewTapAnimationController

- (void)viewDidLoad {
    
    [super viewDidLoad];
}

- (void)setup {
    
    [super setup];
    
    // Init dataArray.
    _dataArray = @[[TapAnimationModel modelWithName:@"YouXianMing" selected:YES],
                   [TapAnimationModel modelWithName:@"NoZuoNoDie" selected:NO],
                   [TapAnimationModel modelWithName:@"Animations" selected:NO]];
    
    // Init TableView.
    self.tableView                = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, self.view.width, self.view.height - 64)
                                                                 style:UITableViewStylePlain];
    self.tableView.delegate       = self;
    self.tableView.dataSource     = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.tableView registerClass:[TableViewTapAnimationCell class] forCellReuseIdentifier:@"TableViewTapAnimationCell"];
    [self.view addSubview:self.tableView];
    
    [self bringTitleViewToFront];
}

#pragma mark - TableView相关方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return _dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    TableViewTapAnimationCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TableViewTapAnimationCell"];
    cell.data                       = _dataArray[indexPath.row];
    [cell loadContent];
    [cell changeStateAnimated:NO];
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    TableViewTapAnimationCell *cell = (TableViewTapAnimationCell *)[tableView cellForRowAtIndexPath:indexPath];
    [cell showSelectedAnimation];
    [cell changeStateAnimated:YES];
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return 80.f;
}

@end

细节

 


目录
相关文章
|
Android开发
Android软键盘状态的切换及其强制隐藏
MainActivity如下:package cc.c; import android.os.Bundle; import android.view.
826 0
自定义状态切换按钮
最近在做一个项目,一个界面的按钮UI给画成了这样(默认状态是蓝色的然后触摸后变成灰色的) UI效果 然后本着给低版本系统APP适配的职业素养(其实是不想画这种按钮),想让UI兄弟给将图标改成整个按钮效果的图片,可是。
918 0
|
iOS开发
【iOS 开发】防止 UIWindow 延迟释放占用状态栏
在展示 app 启动广告等情况下,我们可能需要在界面上叠加一个 UIWindow,但是实测情况下发现,由于 UIWindow 会被系统引用导致延迟释放,在 customWindow 实例被使用完之后,单纯 customWindow.
829 0
滚动标记当前菜单状态
滚动时显示当前主题菜单状态。 运行代码 本文转自懒得安分博客园博客,原文链接:http://www.cnblogs.com/jikey/archive/2013/04/10/3011971.html,如需转载请自行联系原作者
848 0
基于Dialog程序,启动时不显示主窗口,只显示子窗口的实现
实现主窗口隐藏的是SetWindowPos(),从代码很容易理解出来,就是把主窗口的坐标设置为(0,0,0,0),也就是说把主窗口设置为一个点,并且点处于原点处.
1256 0
解决使用tableview的reloadSections刷新之后,sectionFooter有时会消失
//CATransaction解决刷新之后sectionFooter消失的问题 [CATransaction begin]; [CATransaction setCompletionBlock:^{ [self.
1433 0