【问题标题】:Setting image to tableview background将图像设置为 tableview 背景
【发布时间】:2013-04-19 12:44:56
【问题描述】:

我在 tableview 上添加了一个 imageview。我需要将其设置为 tableview 的背面,而不将其设置为 tableview 的背景。

sendSubviewToBack:bgView 也不起作用。有人可以帮忙吗?

【问题讨论】:

  • 一旦阅读我的答案第二个选项它会帮助你。
  • 你的问题解决了吗?
  • 没有。我正在尝试..但似乎没有任何效果..
  • 在此处发布代码后,您还有哪些地方出错了。

标签: ios uitableview background uiimage layer


【解决方案1】:

试试这样,

if objects are in xib ,then take imageview infront of tableview in xib,

(或)

if you are adding in programatically then add imageview before adding the tableview 

(或)

table.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@""]];

(或)

[table bringSubviewToFront:yourImageview];

【讨论】:

    【解决方案2】:

    试试这个

     self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"table_bg_image.png"]];
    

    【讨论】:

    • 我不能使用任何处理背景颜色的属性,因为我的背景颜色是使用通用渐变方法设置的。
    【解决方案3】:

    没有得到你想要的。 另一种来自 XIB 的方法,只需将其添加到 table View 后面的 xib 中,并将 tableView 的背景颜色设置为 clearcolor,这样您就可以看到 tableview 后面的图像。

    【讨论】:

    • 我需要以编程方式进行。
    • 然后按照 Sunny 的指示尝试 tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@""]];
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-24
    • 2015-12-12
    • 1970-01-01
    • 1970-01-01
    • 2017-01-11
    • 2014-06-23
    相关资源
    最近更新 更多