Elton's Blog

给TableView加背景

by Elton on 2010年02月2日, under iPhone

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

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

ATableViewController是UITableViewController的一个子类

相关文章:

  1. 给TableView添加背景
  2. loadView vs viewDidLoad
  3. 为什么要在addsubview:一个view对象后,release它
  4. 如何配置iAd
  5. 如何在iPhone编程中使用UITextField
:,

10 Comments for this entry

Leave a Reply

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...