ios7 UITableViewCell selectionStyle不会回蓝 [英] ios7 UITableViewCell selectionStyle won't go back to blue

查看:102
本文介绍了ios7 UITableViewCell selectionStyle不会回蓝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Xcode 5.0,iOS 7并更新现有应用。 UITableView 所选行现在是灰色的,而不是蓝色。

Xcode 5.0, iOS 7 and updating an existing app. UITableView selected row is now gray, not blue.

根据我的阅读,他们更改了默认 selectionStyle 为灰色。但蓝色仍然是IB中的一个选项, UITableViewCellSelectionStyleBlue 仍然存在。检查新的HIG,看起来他们没有删除蓝色和仍然使用蓝色单元格选择的设置应用程序。

From what I've read they changed the default selectionStyle to gray. But "Blue" is still an option in IB and UITableViewCellSelectionStyleBlue still exists. Checking out the new HIG, it doesn't look like they removed the blue and the "Settings" app still using blue cell selection.

我已经尝试设置值在IB和代码中,但没有运气。关于我需要做什么来获得蓝色选择样式的任何想法?

I've tried setting the value in IB and in code, but no luck. Any ideas on what I need to do to get the blue selection style back?

推荐答案

在iOS7中只有一个selectionStyle,到更改你需要手动执行此操作,如下所示:

There is only one selectionStyle in iOS7, to change you need to do this manually like below:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ 
    ....
    UIView *bgColorView = [[UIView alloc] init];
    bgColorView.backgroundColor = [UIColor colorWithRed:(76.0/255.0) green:(161.0/255.0) blue:(255.0/255.0) alpha:1.0]; // perfect color suggested by @mohamadHafez
    bgColorView.layer.masksToBounds = YES;
    cell.selectedBackgroundView = bgColorView;
    ....
    return cell;
}

这篇关于ios7 UITableViewCell selectionStyle不会回蓝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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