【问题标题】:UITableViewCell disclosure indicator inheriting UIButton's AppearanceUITableViewCell 显示指示器继承 UIButton 的外观
【发布时间】:2014-05-15 14:19:15
【问题描述】:

当我的应用启动时,我设置了[[UIButton appearance] setBackgroundColor:[UIColor someColor]] 以修改整个应用中按钮的外观。但是,这似乎给了我不想要的副作用,即在我的表格视图中更改披露指示器的背景颜色。它似乎只设置了未选中状态,所以如果我按住单元格,背景颜色就会变清晰。

在单元格的accessoryView 上设置背景颜色不起作用,因为我没有使用自己的附件视图,只是将accessoryType 设置为使用披露指示器。

我看到了一些关于尝试更改附件的背景以匹配单元格的背景颜色的其他问题,这似乎涉及使用自定义附件 UIImageView 或在 contentView 而不是单元格上设置背景颜色。后者不适用,因为这不是我遇到的问题,而前者对于“取消覆盖”我正在设置的 UIButton appearance 似乎有点矫枉过正。

有没有办法删除披露指标的自定义 appearance 设置?

编辑:不确定是否重要,但我使用的是自定义UITableViewCells。

【问题讨论】:

    标签: ios objective-c uitableview uibutton


    【解决方案1】:

    当 UIButton 包含在 UITableViewCell 中时,使用 appearanceWhenContainedIn:“重置”外观

    例如:

    [[UIButton appearance] setBackgroundColor:[UIColor redColor]];
    [[UIButton appearanceWhenContainedIn:[UITableViewCell class], nil] setBackgroundColor:[UIColor clearColor]];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-01
      • 1970-01-01
      • 2011-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多