- (void)viewDidLoad {
[super viewDidLoad];
UIColor *clr = nil;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
clr = [UIColor colorWithRed:0.875 green:0.88 blue:0.91 alpha:1];
}else{
clr = [UIColor groupTableViewBackgroundColor];
}
[[self view ] setBackgroundColor:clr];
}
通过UIDevice类发送currentDevice方法,可以得到UIDevice对象,然后检查该对象的userInterfaceIdiom属性。UIUserInterfaceIdiomPad针对Ipad,UIUserInterfaceIdiomPhone针对iphone和ipod touch