通过代码判断iphone4的Retina 屏幕分辨率
#define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
-(void)loadMainView
{
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
UIImage *bigImage = [UIImage imageNamed:@"comment.png"];
UIImage *smallImage = [UIImage imageNamed:@"comment@2x.png"];
if (isRetina)
{
button.frame = CGRectMake(0, 20, bigImage.size.width, bigImage.size.height);
[button setImage:bigImage forState:UIControlStateNormal];
}
else
{
button.frame = CGRectMake(0, 20, smallImage.size.width, smallImage.size.height);
[button setImage:smallImage forState:UIControlStateNormal];
}
[button addTarget:self action:@selector(isButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
[self.window addSubview:button];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
[self loadMainView];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}