DKLoginButton 4.2.0

DKLoginButton 4.2.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布日期最新发布日期2018年9月
SPM支持SPM

DKJone维护。



  • DKJone

DKLoginButton

英文|中文文档
具有酷炫动画且易于使用的登录按钮

Platform Language License CocoaPods

版本

Swift4.2!! 🐱 (其他Swift版本↓)
Swift4.0
Swift3.2
Swift2.0

灵感来自Dribbble

本项目实现了一个具有动画效果的登录按钮,常用于登录/注销和其他操作

正如您在下面的GIF动画演示中所见,您可以在动画旋转后设置按钮到特定状态(失败和成功对应不同的动画)

这些效果被封装在同一个类中,只要按钮继承自该类就可以很容易地使用

演示

Demo GIF Animation

image

推荐使用 CocoaPods

pod 'DKLoginButton'

文件添加

只需下载演示文稿,并将 DKButton 文件夹拖入您的项目中

使用说明

这是一个 UIButton 的子类,在使用前初始化并设置相关属性

	override func viewDidLoad() {
	super.viewDidLoad()
	// set backgrounds
	UIApplication.sharedApplication().setStatusBarStyle(.LightContent, animated: false)
	let bg = UIImageView(image: UIImage(named: "Login"))
	bg.frame = self.view.frame
	self.view.addSubview(bg)
	// init button
	var btn = DKTransitionButton(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width - 64, height: 44))
	btn.backgroundColor = UIColor(red: 1, green: 0, blue: 128.0 / 255.0, alpha: 1)
	btn.center = self.view.center
	btn.frame.bottom = self.view.frame.height - 60
	btn.setTitle("Sign in", forState: .Normal)
	btn.titleLabel?.font = UIFont(name: "HelveticaNeue-Light", size: 14)
	btn.addTarget(self, action: #selector(onTapButton(_:)), forControlEvents: UIControlEvents.TouchUpInside)
	btn.spiner.spinnerColor = UIColor.blackColor()
	self.view.addSubview(btn)
	self.view.bringSubviewToFront(canlogin)
}

如何使用动画

	@IBAction func onTapButton(button: DKTransitionButton) {
	// Start loading animations
	button.startLoadingAnimation()

	if self.canlogin.on {
	    // Success, interface switch
	button.startSwitchAnimation(1, completion: { () -> () in
	let secondVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("SecondViewController")
	secondVC.transitioningDelegate = self
	self.presentViewControllerWithDKAnimation(secondVC, animated: false, completion: nil)
	})
	} else {
    	// Failed, returned and prompted
	    button.startShakeAnimation(1, completion: {
	    // Prompt for logon failure
	    print("badend")
	    })
	}
}

动画返回到登录页

@IBAction func onTapScreen() {
    button.moveToCenterExpand(0) {
	    self.dismissViewControllerAnimated(false, completion: nil)
	}
}