Custom Google Sign-In button - iOS

后端 未结 10 2509
别那么骄傲
别那么骄傲 2020-12-24 01:19

I want to customize Google Sign-In button like below:-

I have tried below links, but none of them helped really much:- How to customize google sign in button?
ht

10条回答
  •  孤城傲影
    2020-12-24 02:15

    For Swift 4: (This is working code Enjoy)

    @IBAction func logimByGoogle(_ sender: Any) {
        GIDSignIn.sharedInstance().delegate = self
        GIDSignIn.sharedInstance().uiDelegate = self
        GIDSignIn.sharedInstance().signIn()
    }
    //MARK:- Google Delegate
    func sign(inWillDispatch signIn: GIDSignIn!, error: Error!) {
    
    }
    
    func sign(_ signIn: GIDSignIn!,
              present viewController: UIViewController!) {
        self.present(viewController, animated: true, completion: nil)
    }
    
    public func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!,
                       withError error: Error!) {
        if (error == nil) {
            // Perform any operations on signed in user here.
            let userId = user.userID                  // For client-side use only!
            let idToken = user.authentication.idToken // Safe to send to the server
            let fullName = user.profile.name
            let givenName = user.profile.givenName
            let familyName = user.profile.familyName
            let email = user.profile.email
            // ...
        } else {
            print("\(error)")
        }
    }
    

提交回复
热议问题