Elton's Blog

Tag: background

给TableView加背景

by on 二.02, 2010, under iPhone

iPhone默认的表格背景很单调,你可以通过加背景图片的方式来给你的应用增添点亮点。可以通过以下方法来给表格添加背景。
你可以在你的delegate类里面添加如下代码:

1
2
3
4
5
6
7
8
9
10
UIView *backgroundView = [[UIView alloc] initWithFrame: window.frame];
backgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"TableViewBackground.png"]];
[window addSubview:backgroundView];
[backgroundView release];
 
yourTableViewController = [[ATableViewController alloc] initWithStyle:UITableViewStyleGrouped];
yourTableViewController.view.backgroundColor = [UIColor clearColor];
[window addSubview:yourTableViewController.view];
 
[window makeKeyAndVisible];

ATableViewController是UITableViewController的一个子类

18 Comments :, more...

DIV+CSS侧边栏自适应高度

by on 八.09, 2009, under Web

1
2
3
4
5
6
7
8
9
10
<div id="container">
  <div id="sidebar1">
    <!-- end #sidebar1 -->
  </div>
 
  <div id="mainContent">
  </div>
 
  <!-- end #container -->
</div>

如上面这个比较经典的两栏布局。 如果sidebar1使用了背景平铺图片或者背景颜色,这时候,如果如果另一侧的mainContent比sidebar1高的话,就会出现sidebar1上半部分是之前指定sidebar1的背景,而下面则是这个container的背景。也就是说sidebar1定义的背景并没有自动随着页面高度的增加而自动延伸下来。

即使你把sidebar1的高度设置成100%也是没有效果的。

解决办法很简单,因为另一侧的mainContent的内容增加了,高度变高了,会自动导致包含它的container的高度也自然增加,所以如果把sidebar1的背景设置在container中就解决了。

如:

1
background: #fff url(../images/left_bg.jpg) repeat-y;
Leave a Comment :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit my friends!

A few highly recommended friends...