你为什么不能设置cell.selectionStyle = UITableViewCellSelectionStyleBlue? [英] Why can't you set the cell.selectionStyle = UITableViewCellSelectionStyleBlue?

查看:581
本文介绍了你为什么不能设置cell.selectionStyle = UITableViewCellSelectionStyleBlue?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了以下问题,但是没有解释,虽然您只需将 cell.SelectedStyle 设置为 UITableViewCellSelectionStyleGray UITableViewCellSelectionStyleNone ,你不能将selectionStyle设置为 UITableViewCellSelectionStyleBlue

I have seen the following questions, but non explain that while you can simply set cell.SelectedStyle to UITableViewCellSelectionStyleGray or UITableViewCellSelectionStyleNone, you can't set it selectionStyle to UITableViewCellSelectionStyleBlue.

他们只提供黑客而不解释。我只是想知道为什么以便我能更好地理解Objective-c

They just offer a hack without explaining. I simply want to know the why so that I can better understand objective-c

UITableViewCellSelectionStyleBlue无效

ios7 UITableViewCell selectionStyle不会再回到蓝色

无法更改UITableView蓝色高亮颜色

推荐答案

你不会喜欢这个答案。从iOS 7开始,设置

Your not going to like the answer then. As of iOS 7, setting

cell.selectionStyle = UITableViewCellselectionStyleBlue;

现在会给你灰色。 Apple在iOS 7中摆脱了它,所以现在selectionStyleBlue不再存在为蓝色..它是灰色的。

will now give you gray. Apple got rid of it in iOS 7, so now selectionStyleBlue no longer exists as blue.. it is gray.

以下是Apple的UITableViewCell类参考文档的引用:

Here is the quote from Apple's Documentation of the UITableViewCell Class Reference:



  • 蓝色

单元格在选中时具有默认背景颜色。

The cell has a default background color when selected.

在iOS 7中,选择颜色不再是蓝色。改为使用UITableViewCellSelectionStyleDefault。

In iOS 7, the selection color is no longer blue. Use UITableViewCellSelectionStyleDefault instead.

在iOS 2.0及更高版本中可用。

Available in iOS 2.0 and later.

当然,我相信你已经找到了,你可以创建一个UIView并将其设置为背景来模拟蓝色选择。

Of course, as I'm sure you have found, you can create a UIView and set it as the background to simulate a blue selection.

以下是该方法的链接:选择时UITableView单元格蓝色突出显示

Here is a link for that approach: UITableView cell blue highlight on selection

修改:

为了清楚起见。 UITableViewCellSelectionStyleBlue使选择样式变为灰色。

Just to be clear. UITableViewCellSelectionStyleBlue makes the selection style gray.

没有UITableViewCell的默认方法使选择样式为蓝色。

There is no default method of UITableViewCell that makes selection style a blue color.

为了使选择样式的颜色不是默认的灰色,你必须在我提供的链接中创建一个自定义的UIView。

In order to make selection style any color other than the default gray, you have to create a custom UIView like in the link I provided.

这篇关于你为什么不能设置cell.selectionStyle = UITableViewCellSelectionStyleBlue?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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