iPhone UITableView PlainStyle with custom background image - done “entirely” in code

后端 未结 5 951
情深已故
情深已故 2021-02-09 08:28

I have been all over the place, seems the UITableView with a static background issue is well documented, but no one with a straight forward solution? Im building my

5条回答
  •  温柔的废话
    2021-02-09 09:03

    You need to set up your controller as a UIViewController, not a UITableViewController. Then add the tableview programmatically above a background imageView.

    @interface SomeController : UIViewController  {
      ...
      UITableView *tableView;
      ...
    }
    @property (nonatomic, retain) UITableView *tableView;
    @end
    
    
    
    @implementation SomeController
    
    @synthesize tableView;
    
    ...
    
    - (void)loadView {
        [super loadView];
        UIImageView *v = [[[UIImageView alloc] initWithFrame:self.view.bounds] autorelease];
        [v setImage:[UIImage imageNamed:@"table_background.png"]];
        [self.view addSubview:v];
    
    
        self.tableView = [[[UITableView alloc] initWithFrame:self.view.bounds] autorelease];
        [self.tableView setBackgroundColor:[UIColor clearColor]];
        [self.view addSubview:self.tableView];
    }
    ...
    @end
    

提交回复
热议问题