サイズ変更して丸めたグループ化された UITableView があります。このテーブルの後ろにビューを配置したいと思います。
[self.tableView addSubview:backgroundView];
[self.tableView sendSubviewToBack:backgroundView];
しかし、うまくいきませんでした。これは私が得るものです:
黒いスペースの代わりに背景が欲しいです。
何か案が?
サイズ変更して丸めたグループ化された UITableView があります。このテーブルの後ろにビューを配置したいと思います。
[self.tableView addSubview:backgroundView];
[self.tableView sendSubviewToBack:backgroundView];
しかし、うまくいきませんでした。これは私が得るものです:
黒いスペースの代わりに背景が欲しいです。
何か案が?
どう[self.tableView setBackgroundView:backgroundView];
ですか?
初心者なのでご了承ください。この問題に遭遇したところ、2 つの解決策が見つかりました。私の場合、UITableView オブジェクトを使用していました。
まず、背景画像をアプリのディレクトリに追加します。私は「サポートファイル」に私のものを入れました
イメージを UIColor オブジェクトとして追加できます。
...
[resultsTable setBackGroundColor:setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"background.jpg"]]];
...
この方法の問題点は、背景画像をパターンとして扱っているため、背景画像が繰り返されることです。
より良い方法:
// Create a string to store the path location of your image, otherwise you would have to provide an exact path name
NSString *backPath = [[NSBundle mainBundle] pathForResource:@"background"
ofType:@"jpg"];
// Create a UIImage Object to store the image.
UIImage *bgImage = [[UIImage alloc ] initWithContentsOfFile:backPath];
// Create a UIImageView which the TableView
UIImageView *bgView = [[UIImageView alloc]initWithImage:bgImage];
// Set your TableView's background property, it takes a UIView Obj.
[resultsTable setBackgroundView: bgView];
.....