Ben*_*ard 4 iphone cocoa-touch uiimageview ios ios6
在发布时,我正从我的启动图像淡入应用程序的界面.为了达到这个目的,我正在添加一个UIImageView"Default.png"并在之前动画化它的alpha makeKeyAndVisible.
Default.png是否应始终返回启动映像的特定于设备(或特定于分辨率)的版本?或者我应该检查屏幕的界限和比例来选择合适的视网膜与非视网膜和3.5英寸4英寸屏幕?
我希望Default.png的行为与其他图像资源非常相似 - 支持时使用@ 2x版本(以及iPhone 5上的-568h版本).但是我在模拟器中的实验让我相信不然.运行4英寸模拟器,使用3.5英寸图像.这会导致飞溅图像不会延伸到屏幕底部.下面的屏幕截图显示了动画中期动画.

不幸的是我没有每个设备所以无法确认这是否只是模拟器的一个怪癖.
简而言之,我想确保视网膜图像用于视网膜设备,4英寸图像用于4英寸设备.
小智 6
这是我的代码
- (BOOL) application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
[self.window makeKeyAndVisible];
[self _startLaunchAnimation];
return YES;
}
- (void)_launchAnimation {
CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height;
UIImageView *launchImageView = (UIImageView*)[self.window viewWithTag:1000];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionNone
forView:self.window
cache:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
[launchImageView setAlpha:0.0];
[launchImageView setFrame:CGRectMake(-60.0f, 0.0f, 320.0f, screenHeight)];
[UIView commitAnimations];
}
- (void)_startLaunchAnimation {
CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height;
NSString *imageName = nil;
if (screenHeight == 568.0f) {
imageName = @"Default-568h.png";
} else {
imageName = @"Default.png";
}
UIImage *image = [UIImage imageNamed:imageName];
UIImageView *launchImageView = [[UIImageView alloc] initWithImage:image];
[launchImageView setTag:1000];
[self.window addSubview:launchImageView];
[NSTimer scheduledTimerWithTimeInterval:2.0
target:self
selector:@selector(_launchAnimation)
userInfo:nil
repeats:NO];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2415 次 |
| 最近记录: |