iOS "系统设置"转场时cell的阴影渐变效果

今天看了系统设置里, 点击cell跳转控制器时, 返回时cell的选中效果有个动画渐变效果


渐变效果.gif

实现过程

a.设置cell选中类型

cell.selectionStyle = UITableViewCellSelectionStyleDefault;
/** 其实三种效果感觉都一样的
    UITableViewCellSelectionStyleBlue,
    UITableViewCellSelectionStyleGray,
    UITableViewCellSelectionStyleDefault
 **/

b.设置Selected状态
在viewWillAppear方法中, 设置cell的Selected状态

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

   // 取出选中的indexPath
    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
    // 取出选中的cell
    UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
    // 设置selected, 加上动画
    [cell setSelected:NO animated:YES];
}

c. 完成 (非常简单)


完成效果.gif
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容