如何使UITableViewCell显得已禁用? [英] How do I make a UITableViewCell appear disabled?

查看:110
本文介绍了如何使UITableViewCell显得已禁用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解 UITableview:如何禁用某些行而不是其他行的选择 cell.selectionStyle = UITableViewCellSelectionStyleNone ,但是如何制作单元格(或任何 UIView 会显示为禁用(变灰),如下所示?

I know about UITableview: How to Disable Selection for Some Rows but Not Others and cell.selectionStyle = UITableViewCellSelectionStyleNone, but how do I make a cell (or any UIView for that matter) appear disabled (grayed-out) like below?

推荐答案

您只需禁用单元格的文本字段即可将其显示为灰色:

You can just disable the cell's text fields to gray them out:

Swift 4.x

cell!.isUserInteractionEnabled = false
cell!.textLabel!.isEnabled = false
cell!.detailTextLabel!.isEnabled = false

这篇关于如何使UITableViewCell显得已禁用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆