Splashpage 类似于 Twitter 和 Swift



我正在为一家连锁超市开发一个应用程序。快到这个应用程序的尽头了,我想念启动页面。我真的很想做Twitter应用程序相同的启动页面,鸟的图标大小增加,直到消失,显示应用程序的主屏幕。这可能吗?

原生

我按照本教程创建了动画

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

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

步骤 -2

我们使用徽标作为进入主视图的窗口的策略可以在CALayer上实现为蒙版。每个 CALayer 都有一个遮罩属性,该属性也是 CALayer 并允许您遮罩主图层或视图。苹果是这样描述它的:

遮罩层的 Alpha 通道决定了主层的内容和背景的显示量。完全或部分不透明的像素允许通过底层内容显示,但完全透明的像素会阻止该内容。

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")

第三方应用

尝试CBZSplashView或SKSplashViewMSTwitterSplashScreen,就像在Twitter启动动画中一样,你会得到

最新更新