【问题标题】:change table view's cell selection color更改表格视图单元格选择颜色
【发布时间】:2011-04-27 03:42:34
【问题描述】:

我们可以改变表格视图的选择颜色,即单元格,默认为蓝色,那么,我们可以将其更改为任何其他颜色吗?

问候

【问题讨论】:

    标签: iphone


    【解决方案1】:

    代码中的这种方式

    aCell.selectedBackgroundView = [[[UIImageView alloc] 
          initWithImage:[UIImage imageNamed:@"selectedBackground.png"]] autorelease];
    

    或者你可以在界面生成器中将其设置为灰色,我认为蓝色和灰色是所有可用的,而无需创建 be 视图

    【讨论】:

    • 感谢 aaron,我已经使用了这个 sn-p,我不想提供图像,我们不能只着色。感谢您的回复...感谢
    • 进一步谷歌搜索将我带到了这个stackoverflow.com/questions/281515/…
    【解决方案2】:

    另一种不需要图像文件的方法是:

    UIView *bgView = [[UIView alloc] init];
    // At least on iOS6 you don't to size the view for this to work.
    bgView.backgroundColor = [UIColor grayColor];
    aCell.selectedBackgroundView = bgView;
    

    【讨论】:

      猜你喜欢
      • 2018-10-04
      • 2015-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-10
      • 2012-05-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多