本文是在看week demo的时候发现的一种实现方式
直接步入正题
本例使用了CGAffineTransform
来实现
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
[self initWeexSDK];
self.window.rootViewController = [[WXRootViewController alloc] initWithRootViewController:[self demoController]];
[self.window makeKeyAndVisible];
[self startSplashScreen];
return YES;
}
#pragma mark animation when startup
- (void)startSplashScreen
{
UIView* splashView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
splashView.backgroundColor = WEEX_COLOR;
UIImageView *iconImageView = [UIImageView new];
UIImage *icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"weex-icon" ofType:@"png"]];
if ([icon respondsToSelector:@selector(imageWithRenderingMode:)]) {
iconImageView.image = [icon imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
iconImageView.tintColor = [UIColor whiteColor];
} else {
iconImageView.image = icon;
}
iconImageView.frame = CGRectMake(0, 0, 320, 320);
iconImageView.contentMode = UIViewContentModeScaleAspectFit;
iconImageView.center = splashView.center;
[splashView addSubview:iconImageView];
[self.window addSubview:splashView];
float animationDuration = 1.4;
CGFloat shrinkDuration = animationDuration * 0.3;
CGFloat growDuration = animationDuration * 0.7;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
[UIView animateWithDuration:shrinkDuration delay:1.0 usingSpringWithDamping:0.7f initialSpringVelocity:10 options:UIViewAnimationOptionCurveEaseInOut animations:^{
CGAffineTransform scaleTransform = CGAffineTransformMakeScale(0.75, 0.75);
iconImageView.transform = scaleTransform;
} completion:^(BOOL finished) {
[UIView animateWithDuration:growDuration animations:^{
CGAffineTransform scaleTransform = CGAffineTransformMakeScale(20, 20);
iconImageView.transform = scaleTransform;
splashView.alpha = 0;
} completion:^(BOOL finished) {
[splashView removeFromSuperview];
}];
}];
} else {
[UIView animateWithDuration:shrinkDuration delay:1.0 options:0 animations:^{
CGAffineTransform scaleTransform = CGAffineTransformMakeScale(0.75, 0.75);
iconImageView.transform = scaleTransform;
} completion:^(BOOL finished) {
[UIView animateWithDuration:growDuration animations:^{
CGAffineTransform scaleTransform = CGAffineTransformMakeScale(20, 20);
iconImageView.transform = scaleTransform;
splashView.alpha = 0;
} completion:^(BOOL finished) {
[splashView removeFromSuperview];
}];
}];
}
}