2016-01-23 35 views
-2

我正在开发超市连锁申请。几乎到了这个应用程序的结尾,我想念splashpage。我真的很想做一个Twitter应用程序的同一个splashpage,这个应用程序是鸟的图标大小增加直到它消失的那个,显示应用程序的主屏幕。这有可能吗?Splashpage与Swift类似的Twitter吗?

回答

1

本地

我跟着this教程创建动画

首先,让我们添加的窗口上的屏幕截图:

let imageView = UIImageView(frame: self.window!.frame) 
imageView.image = UIImage(named: "twitterscreen") 
self.window!.addSubview(imageView) 

步-2

我们将徽标用作窗口的策略进入主视图可以作为CALayer上的掩码来实现。每个CALayer都有一个掩码属性,它也是一个CALayer,并允许您屏蔽主图层或视图。下面是如何苹果描述它:

掩模层的α信道确定如何主层的内容的多和背景示出了穿过。完全或部分不透明像素允许底层内容显示,但完全透明的像素会遮挡该内容。

let keyFrameAnimation = CAKeyframeAnimation(keyPath: "bounds") 
keyFrameAnimation.duration = 1 
keyFrameAnimation.timingFunctions = [CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut), CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)] 
let initalBounds = NSValue(CGRect: mask!.bounds) 
let secondBounds = NSValue(CGRect: CGRect(x: 0, y: 0, width: 90, height: 90)) 
let finalBounds = NSValue(CGRect: CGRect(x: 0, y: 0, width: 1500, height: 1500)) 
keyFrameAnimation.values = [initalBounds, secondBounds, finalBounds] 
keyFrameAnimation.keyTimes = [0, 0.3, 1] 
self.mask!.addAnimation(keyFrameAnimation, forKey: "bounds") 

第三方应用

尝试CBZSplashViewSKSplashViewMSTwitterSplashScreen,对于同样喜欢在Twitter上飞溅的动画,你会得到

+0

非常感谢您information..I还在犹豫着要使用外部库,或者使用我向你指出的代码。也许我已经指出的代码更简单,因为它已经用Swift编写,而第三方库是用Object-c编写的,但最重要的是,使用Pod我真的很喜欢 – macuser

+0

选择是你的,如果你如果你实现本地代码,你是国王,你可以自己定制任何东西。使用pod需要创建桥头(你需要另一个支持)。 –