Swift 谷歌登录按钮定制
作为一个初学者,我试图改变谷歌登录按钮的高度,但还没有弄清楚 起初我实现为一个视图,但它看起来像这样,我无法更改高度 之后,我创建了一个按钮,这样我可以改变高度,但谷歌视图消失了 我怎样才能解决这个问题Swift 谷歌登录按钮定制,swift,Swift,作为一个初学者,我试图改变谷歌登录按钮的高度,但还没有弄清楚 起初我实现为一个视图,但它看起来像这样,我无法更改高度 之后,我创建了一个按钮,这样我可以改变高度,但谷歌视图消失了 我怎样才能解决这个问题 @IBAction func googleSignInButtonPressed(_ sender: GIDSignInButton) { GIDSignIn.sharedInstance().signIn() } // MARK: -
@IBAction func googleSignInButtonPressed(_ sender: GIDSignInButton) {
GIDSignIn.sharedInstance().signIn()
}
// MARK: -ViewDidLoad
override func viewDidLoad() {
super.viewDidLoad()
setupAppleButton()
setupSignupAnimation()
GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID
GIDSignIn.sharedInstance().delegate = self
}
extension SignupViewController : GIDSignInDelegate {
@available(iOS 9.0, *)
func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any])
-> Bool {
return GIDSignIn.sharedInstance().handle(url)
}
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) {
if let error = error {
if (error as NSError).code == GIDSignInErrorCode.hasNoAuthInKeychain.rawValue {
print("The user has not signed in before or they have since signed out.")
} else {
print("\(error.localizedDescription)")
}
return
}
guard let authentication = user.authentication else { return }
let credential = GoogleAuthProvider.credential(withIDToken: authentication.idToken,
accessToken: authentication.accessToken)
Auth.auth().signIn(with: credential) { (authResult, error) in
if let error = error {
print("Error occurs when authenticate with Firebase: \(error.localizedDescription)")
return
}
guard let uid = Auth.auth().currentUser?.uid else {return}
let userData : [String: Any] = ["userId": user.userID, "fullName": user.profile.name,"givenName": user.profile.givenName,"familyName": user.profile.familyName,"email": user.profile.email]
self.dismiss(animated: true, completion: nil)
let db = Firestore.firestore()
db.collection("users").document(uid).setData(userData, merge: true)
}
}
}
亲爱的@Ambroisa,您需要做的就是在故事板上放置一个自定义UIButton(在故事板UI上自定义您的按钮),并将其与以下属性链接:ibvar signInButton:GIDSignInButton!在UIViewController中。从下面给出的链接中阅读第3点:-.@abhimanyurator我这样做了,但问题是约束并没有应用到google按钮,无论是编程还是情节提要。它的高度仍然不等于apple登录按钮,就像第一张图片一样,您需要创建自定义UIButton而不是GIDSignInButton,并在该按钮操作中调用google SignIn函数。不要使用GIDSignInButton。亲爱的@Ambroisa,您只需在情节提要上放置一个自定义UIButton(在情节提要UI上自定义您的按钮),并将其与以下属性链接:ibsigninButton:GIDSignInButton!在UIViewController中。从下面给出的链接中阅读第3点:-.@abhimanyurator我这样做了,但问题是约束并没有应用到google按钮,无论是编程还是情节提要。它的高度仍然不等于apple登录按钮,就像第一张图片一样,您需要创建自定义UIButton而不是GIDSignInButton,并在该按钮操作中调用google SignIn函数。不要使用GIDSignInButton。