RevealingSplashView 0.6.0

RevealingSplashView 0.6.0

测试经过测试
Lang语言 SwiftSwift
许可 MIT
发布最新发布2018 年 9 月
SPM支持 SPM

Chris Jimenezweak 维护。



Banner

Build Status codecov.io CocoaPods Compatible Carthage compatible Awesome Language GitHub license

RevealingSplashView

一个动画并揭示其内容的启动画面,灵感来自 Twitter 启动画面。

RevealingSplashView

⭐️特性

  • 自定义揭示图标图像。
  • 自定义图标图像颜色。
  • 自定义图标图像大小。
  • 自定义背景颜色。
  • 自定义动画持续时长。
  • 自定义动画延迟。
  • 提供多种动画进行选择。
  • 易于使用😉.

:octocat: 安装

要在 CocoaPods 上获取 RevealingSplashView,只需将 pod 'RevealingSplashView' 添加到您的 Podfile 中,然后运行 pod install。您也可以将 GitHub 添加到您的 Carthage 文件中。

如果您使用 Carthage,您只需通过在 Carthage 文件中添加 github "PiXeL16/RevealingSplashView" 来安装它。

使用 Swift 2.3 吗?

如果您使用 Swift 2.3,请使用 0.0.6 版本。

🤘用法

视频教程

Rebeloper 创建了一个优秀的 视频教程,您可以在其中学习如何使用这个控件!您还可以查看下面的文档。

使用方法非常简单,只需在您的入口 ViewController 中初始化 RevealingSplashView,并在 viewDidLoad() 函数中将其添加到视图中。然后调用 startAnimation()

import RevealingSplashView

override func viewDidLoad() {
        super.viewDidLoad()

        //Initialize a revealing Splash with with the iconImage, the initial size and the background color
        let revealingSplashView = RevealingSplashView(iconImage: UIImage(named: "twitterLogo")!,iconInitialSize: CGSize(width: 70, height: 70), backgroundColor: UIColor(red:0.11, green:0.56, blue:0.95, alpha:1.0))

        //Adds the revealing splash view as a sub view
        self.view.addSubview(revealingSplashView)

        //Starts animation
        revealingSplashView.startAnimation(){
            print("Completed")
        }

    }

理想情况下,您的 iconInitialSize 应该与 LaunchScreen.storyboard 中图标的大小相匹配。

因此,如果您在 LaunchScreen.storyboard 中将约束设置为 80 个 高度 和 80 个 宽度,则应将相同的尺寸设置为 RevealingSplashView 的初始尺寸。

自定义图标颜色

您还可以更改 iconImage 的颜色。

import RevealingSplashView

override func viewDidLoad() {
        super.viewDidLoad()
        
        //Initialize a revealing Splash with with the iconImage, the initial size and the background color
        let revealingSplashView = RevealingSplashView(iconImage: UIImage(named: "twitterLogo")!,iconInitialSize: CGSize(width: 70, height: 70), backgroundColor: UIColor(red:0.11, green:0.56, blue:0.95, alpha:1.0))

        revealingSplashView.useCustomIconColor = true
        revealingSplashView.iconColor = UIColor.red

        //Adds the revealing splash view as a sub view
        self.view.addSubview(revealingSplashView)

        //Starts animation
        revealingSplashView.startAnimation(){
            print("Completed")
        }

    }

这将更改动画前的实际图标颜色为红色。

自定义背景图片

您还可以更改 backgroundImage 的背景图片。

import RevealingSplashView

override func viewDidLoad() {
        super.viewDidLoad()
        
        //Initialize a revealing Splash with with the iconImage, the initial size and the background color
        let revealingSplashView = RevealingSplashView(iconImage: UIImage(named: "twitterLogo")!, iconInitialSize: CGSize(width: 70, height: 70), backgroundImage: UIImage(named: "BackgroundImage")!)

        revealingSplashView.useCustomIconColor = false
        revealingSplashView.iconColor = UIColor.red

        //Adds the revealing splash view as a sub view
        self.view.addSubview(revealingSplashView)

        //Starts animation
        revealingSplashView.startAnimation(){
            print("Completed")
        }

    }

使用NavigationBar或TabBar?

如果您使用 NavigationBarTabBar 作为入口视图控制器,那么动画可能会看起来偏移一些像素。这里有几个选项:与其将 RevealingSplashView 添加到 ViewController 中,不如将其添加到 window 中。

let window = UIApplication.sharedApplication().keyWindow
window?.addSubview(revealingSplashView)

您也可以创建一个 另一个 入口视图控制器。然后将 RevealingSplashView 添加到该 ViewController 而不是具有 NavigationBarTabBar 的那个。然后,在 RevealingSplashView 的动画完成后,您可以切换到 NavigationViewController。

👍动画类型

有多种动画可供选择,只需设置 RevealingSplashViewanimationType 属性。

Twitter

这是Twitter应用使用的默认动画。如果未设置`animationType`,则将默认为此动画。

RevealingSplashView

HeartBeat

类似于心跳动画,但与其他动画不同,这个特殊动画允许你在调用函数之前继续动画。这可能会比快速的启动和等待旋转轮更容易让用户感到娱乐,如果应用需要获取更多数据。

要使用心跳动画,您应该按正常方式调用startAnimation(),然后继续进行您的网络或后台任务。完成后,只需调用

.heartAttack = true

并且启动画面应该消失。

HeartBeatAnimation

Rotate Out

类似于Twitter的一个,但在缩小的时候旋转。

revealingSplashView.animationType = SplashAnimationType.rotateOut

RotateOutAnimation

Pop and Zoom Out

连续弹出视图几次并放大。

revealingSplashView.animationType = SplashAnimationType.popAndZoomOut

RotateOutAnimation

Squeeze and Zoom Out

挤压视图并放大。

revealingSplashView.animationType = SplashAnimationType.squeezeAndZoomOut

RotateOutAnimation

摆动缩放

摆动视图并缩放。

revealingSplashView.animationType = SplashAnimationType.swingAndZoomOut

RotateOutAnimation

晃动缩放

晃动视图并缩放。

revealingSplashView.animationType = SplashAnimationType.wobbleAndZoomOut

RotateOutAnimation

TODO

  • 更好的代码覆盖率
  • 更多动画

👽作者

Chris Jimenez - http://code.chrisjimenez.net, @chrisjimeneznat

🍺捐赠

如果您想为我买杯啤酒,可以向以下币地址捐款

BTC

1BeGBew4CBdLgUSmvoyiU1LrM99GpkXgkj

ETH

0xa59a3793E3Cb5f3B1AdE6887783D225EDf67192d

LTC

Ld6FB3Tqjf6B8iz9Gn9sMr7BnowAjSUXaV

许可

《RevealingSplashView》软件采用MIT授权协议发布。详见LICENSE