看看UIAppearance
協議。您可以指定表視圖的背景色中所含特定視圖控制器類全局或當:
UITableView *appearance = [UITableView appearanceWhenContainedIn:[MyTableViewController Class], [MyOtherTableViewController class], nil];
appearance.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"backgroundPattern.png"]];
你可以把這個在您的應用程序委託的application:didFinishLaunchingWithOptions:
方法。
此外,view
和tableView
屬性UITableViewController
指向相同的東西,所以你不需要同時設置。
編輯
嘗試看標題Customizing the Appearance of UIKit Controls 2012年的WWDC視頻。他們演示UIAppearance
協議以及您可能會覺得有用的主題設計模式。
我試過了,但沒有變化。我把代碼放入init方法「//自定義初始化」,並在viewdidload中嘗試,我也搜索了幾次,但沒有運氣。 – Laszlo
最後但並非最不重要的子類現在完美。 – Laszlo