美文网首页iOS开发记录ios实用开发技巧
iOS "系统设置"转场时cell的阴影渐变

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

作者: 大头herob | 来源:发表于2017-06-28 17:26 被阅读103次

今天看了系统设置里, 点击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

相关文章

网友评论

    本文标题:iOS "系统设置"转场时cell的阴影渐变

    本文链接:https://www.haomeiwen.com/subject/opwucxtx.html