if let number2 = number2 {
if let fUnumber2 = Int(number2) {
// ...
if let number2 = number2, let fUnumber2 = Int(number2) {
// ...
php myScript.php
. let userID = Auth.auth().currentUser?.uid
ref.child("users").child(userID!).observeSingleEvent(of: .value, with: { (snapshot) in
// Get user value
let value = snapshot.value as? NSDictionary
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
guard let fromVC = transitionContext.viewController(forKey: .from),
let fromSnapshot = fromVC.view.snapshotView(afterScreenUpdates: true),
let toVC = transitionContext.viewController(forKey: .to),
let toSnapshot = toVC.view.snapshotView(afterScreenUpdates: true)
else {
return
}
let containerView = transitionContext.containerView
toSnapshot.frame.origin.x = containerView.frame.width
containerView.addSubview(fromSnapshot)
containerView.addSubview(toVC.view)
containerView.addSubview(toSnapshot)
// fromVC.view.isHidden = true
// toVC.view.isHidden = true
UIView.animate(withDuration: duration, delay: 0, options: [.curveEaseInOut], animations: {
fromSnapshot.frame.origin.x = -(containerView.frame.width / 2.0)
toSnapshot.frame.origin.x = 0
}) { _ in
// toVC.view.isHidden = false
fromSnapshot.removeFromSuperview()
toSnapshot.removeFromSuperview()
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
}
}
final class ModalAnimator: NSObject, UIViewControllerAnimatedTransitioning {
var isPresenting: Bool
let duration: TimeInterval = 3
init(isPresenting: Bool) {
self.isPresenting = isPresenting
}
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?)
-> TimeInterval {
return duration
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
guard let fromVC = transitionContext.viewController(forKey: .from),
let toVC = transitionContext.viewController(forKey: .to),
let snapshot = toVC.view.snapshotView(afterScreenUpdates: true)
else { return }
let containerView = transitionContext.containerView
snapshot.frame = fromVC.view.frame
containerView.addSubview(toVC.view)
containerView.addSubview(snapshot)
fromVC.view.isHidden = true
UIView.animate(withDuration: duration, animations: {
snapshot.transform = CGAffineTransform(rotationAngle: .pi)
}) { succes in
fromVC.view.isHidden = false
snapshot.removeFromSuperview()
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
}
}
}