GithubHelp home page GithubHelp logo

takuoka / tksubmittransition Goto Github PK

View Code? Open in Web Editor NEW
2.3K 43.0 228.0 10.48 MB

Animated UIButton of Loading Animation and Transition Animation. Inspired by https://dribbble.com/shots/1945593-Login-Home-Screen

License: MIT License

Swift 74.06% Ruby 25.94%
transition-animation swift animation library

tksubmittransition's Introduction

TKSubmitTransition

Platform Language License CocoaPods

Inpired by https://dribbble.com/shots/1945593-Login-Home-Screen

I created Animated UIButton of Loading Animation and Transition Animation.

As you can see in the GIF Animation Demo below, you can find the “Sign in” button rolling and after that, next UIViewController will fade-in.

I made them as classes and you can use it with ease.

Objective-C version is here.

Demo

Demo GIF Animation

Installation

Cocoapods

Swift 5

pod 'TKSubmitTransition', :git => 'https://github.com/entotsu/TKSubmitTransition.git'

Swift 4

pod 'TKSubmitTransition', :git => 'https://github.com/entotsu/TKSubmitTransition.git', :branch => 'swift4'

Swift 3

pod 'TKSubmitTransition', :git => 'https://github.com/entotsu/TKSubmitTransition.git', :tag => '2.0'

Swift 2 & Below

pod 'TKSubmitTransition', '~> 0.2' 

Manually

Drag all the files from SubmitTransition/Classes into your project.

Usage

Storyboard

Just drag a UIButton on to your storyboard and change the custom class to TKSubmitTransition in the identity inspector.

Button

Change the settings of the button via the storyboard.

Settings

Then create an IBOutlet to your view controller.

IBOutlet

You can now move on to Animation Method for further instructions.

Programatically

You can use TKTransitionSubmitButton just like any other UIButton. It works practically the same.

Add this at the top of your file:

import SubmitTransition

Then create a variable above your view did load for the button

var bin: TKTransitionSubmitButton!

then finally in the view did load add the button

btn = TKTransitionSubmitButton(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width - 64, height: 44))
btn.center = self.view.center
btn.frame.bottom = self.view.frame.height - 60
btn.setTitle("Sign in", for: UIControlState())
btn.titleLabel?.font = UIFont(name: "HelveticaNeue-Light", size: 14)
self.view.addSubview(btn)

Animation Method

Use this to animate your button. Follow the steps in Delegation to setup the transition.

func didStartYourLoading() {
  btn.startLoadingAnimation()
}

func didFinishYourLoading() {
  btn.startFinishAnimation {
    //Your Transition
    let secondVC = SecondViewController()
    secondVC.transitioningDelegate = self
    self.presentViewController(secondVC, animated: true, completion: nil)
  }
}

Networking

If you are running requests to a server and are waiting a responce, you can use something like this to stop and start the animation:

// start loading the button animations
button.startLoadingAnimation()

// run query in background thread
async.background {
  let query = PFQuery(className: "Blah")
  query.whereKey("user", equalTo: user)
	let results = try! query.findObjects()
  
	if results.count == 0 {
		// insert alertView telling user that their details don't work
	}
	else {
		// return to main thread to complete login
		async.main {
                        // tell the button to finish its animations
			button.startFinishingAnimation(1) {
			        let sb = UIStoryboard(name: "Main", bundle: nil)
	            	        let vc = sb.instantiateViewController(withIdentifier: "MainVC")
			        vc.transitioningDelegate = self
			        self.present(vc, animated: true, completion: nil)
                        }
		}
	}

Thanks to @sarfrazb for pointing this out.

TKFadeInAnimator

This Library also supply fade-in Animator Class of UIViewControllerAnimatedTransitioning.

Please use This for transition animation.

Delegation

Make sure your class implements the UIViewControllerTransitioningDelegate protocol like so

class ViewController: UIViewController, UIViewControllerTransitioningDelegate {

Setup the transitioning delegate

secondVC.transitioningDelegate = self

Implement the delegate

Swift 3/4

func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
  return TKFadeInAnimator(transitionDuration: 0.5, startingAlpha: 0.8)
}

func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
  return nil
}

Swift 2 & Below

// MARK: UIViewControllerTransitioningDelegate
func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
  let fadeInAnimator = TKFadeInAnimator()
  return fadeInAnimator
}

func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
  return nil
}

If you need any help with the setup feel free to look at the sample or create an issue.

Contribution

  • If you've found a bug, please open an issue.
  • If you've a feature request, please open a pull request
  • Please check any closed issues before you open a new one!

tksubmittransition's People

Contributors

abdulla-allaith avatar anirudhamahale avatar dinggong avatar hiro-nagami avatar jesster2k10 avatar julpanucci avatar n8stowell82 avatar nahitheper avatar nhatletien avatar noisyscanner avatar rishabhtayal avatar sandeepbol avatar saroar avatar stepan avatar takuoka avatar xbeg9 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tksubmittransition's Issues

Swift 3?

Hey, when will the Swift 3 version be coming out? As Xcode is now final and iOS 10 is out?

Cheers

Button inside subview only animates (fill) subview

If I have TKTransitionSubmitButton inside a UIView that is the subview of the superview, the color filling animation only happens inside the immediate superview of the button. How to make it fill the whole screen?

Swift 5: Use of undeclared type 'TKTransitionSubmitButton'

Hello,
Thanks for this amazing library.

I wanted to try it out and for the life of it, I am unable to get it to work. I get his error from XCode in my Viewcontroller after linking the button from the storyboard.

Use of undeclared type 'TKTransitionSubmitButton'

I have also tried the only code mode. I get the following error at the import import SubmitTransition

No such module 'SubmitButton'

The readme does say it supports Swift 5 so I am wondering what could be the issue.
I am using the following link in my podfile

pod 'TKSubmitTransition', :git => 'https://github.com/entotsu/TKSubmitTransition.git'

More details:
Swift 5
iOS 13.0

EXC_bad_access

when calling btn.startLoadingAnimation(), I get this error with Swift 4

Stop Animation on returnToOriginalState()

I just made a quick change to returnToOriginalState() in TKSubmitButton.swift by adding self.spiner.stopAnimation() to the function. Is that how you intended to cancel the spinner?

Build errors in Swift file

When building it's giving the following error,

Installed through CocoaPods link v2.0, Xcode 9 - Swift 3 - iOS11

"TransitionSubmitButton.Swift"
Property cannot be marked @IBInspectable because its type cannot be represented in Objective-C

Any idea's?

Segue from VC to Tab Bar VC

So in my StoryBoard i have the Login screen with the TKSubmitTransition button on it.

The button has a segue which first goes to a CustomNavigationController, then goes to a Custom Tab Bar View Controller. Then the first index to load in the tab bar is another Home View Controller.

Now my question is how i can fade my screen from the Login Screen to the Home View Screen?

In my LoginVC i performSegue and try to do
destinationViewController.transitioningDelegate = self

However, destinationVC is showing up as CustomNavVC and none of my UIViewControllerTransitioningDelegate functions in my LoginVC are being called?!

Thanks.

Cancelling animation

Hi, this should be an easy one but can't seem to figure it out. Any help please.

If for instance a login/ signup fails, how does one cancel animation? ...

Thanks

Pod broken

Hi, I use the pod and notice that I need to fix something in order to get it working.

I compared it with the code in github and the code I got from pod install is difference from the source here (e.g: NSTimerEx.swift)

Could you check it out and update the pod if needed ?

customised color?

Hi there, is that possible to make colour to be customised? I know I can change the value, but I don't want to unlock the file. But I want to keep the pod file unchanged. Thanks

BUG?

Hello sir, thanks for your library.
i'm trying to implement it when user logged in to expand the animation then move to the second view controller ( it is like this FirstViewController -> navigationController -> SecondViewcontroller )

but when the animation expend it looks like i see the first viewcontroller pushed then i see it moving to the second... why ? ( btw i'm using performSegue, present not working i don't know why...)

thanks you for your help :)

Transition with keyboard essue

I'm doing a login interface and I'm having a little bug you can help me. It's happening this:

https://youtu.be/DnrC1mOci3Y

It's going from a view controller to a tab view controller.

I think that's happening because of the keyboard, but I don't know how to solve it.

¿Any ideas? Thanks!

CGRectEx classes can not be called

Hi there, I am new to iOS, the sample code has btn.frame.bottom which are used by CGRectEx.swift. However if i am using cocopods to install TKSubmitTransition, all CGRectEx method can not be used. Is this because cocopods or use_framework! ? Thanks for the help

Spinner position wrong

It is not working properly when you apply equals height contraint to your Button to superview.

It is not working dynamic height button.

Failed to set user defined color

I haven't had any luck using the Swift version of this.

I'm receiving the following output in the console:

2015-11-12 16:16:19.825 SubmitTransition[8616:2039351] Failed to set (normalBackgroundColor) user defined inspected property on (SubmitTransition.TKTransitionSubmitButton): [<SubmitTransition.TKTransitionSubmitButton 0x7f98f0c264e0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key normalBackgroundColor. 2015-11-12 16:16:19.826 SubmitTransition[8616:2039351] Failed to set (highlightedBackgroundColor) user defined inspected property on (SubmitTransition.TKTransitionSubmitButton): [<SubmitTransition.TKTransitionSubmitButton 0x7f98f0c264e0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key highlightedBackgroundColor.

Using Within Objective-C Project

I'm having problems getting the spinner to work when using this within an Objective-C project, works fine in the original Swift one and everything else works fine but the spinner in the Objective-C project.

Any ideas?

Storyboard support

Trying to use this with a button defined in a storyboard. Using @IBOutlet weak var loginButton: TKTransitionSubmitButton!, when loginButton.startLoadingAnimation() is called it crashes with fatal error: unexpectedly found nil while unwrapping an Optional value.

Seque to tabbar Controller

I've been working on transitioning the button animation to a tabbar controller but no luck. Is there a way you can help me with this? Hw do i seque to the homeVC of my tabbar controller?
Many thanks in advance :)

Hi there

Using this with iOS 9 and I had to make a few changes for swift 2. It's working great except for the spinner not showing. any ideas?

the SpinerLayer isn't showing when call the method 'startLoadingAnimation()'

With Xcode Version 8.3.3 (8E3004b), I create a loginAndRegister Button, when I click the button, I want to call the 'startLoadingAnimation()' Method, but the sipnerLayer with default configuration won't show on the button.
I didn't modify any file which in the TKSubmitTransition folder. Any analysis for it ?Thanks!

Swift 3.1

Doesn't appear to build with Swift 3.1. I can probably jump in there and update the code if this is desired by others and the library is still being actively worked. Seems like some fairly simple updates

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.