GIDSignInButtonStyle.Standard => 230x48
GIDSignInButtonStyle.Wide => 312x48
GIDSignInButtonStyle.IconOnly => 48x48
- Custom image
- Custom button size
- Circular shape
To get started, implement a standard Google Sign-In button with instructions in this tutorial:
Google Sign-In for iOS - Create a GIDSignInButton programmatically in Swift
Then remove the GIDSignInButton and add a UIButton instead:
var btnSignIn : UIButton!
override func viewDidLoad() {
super.viewDidLoad()
...
let btnSize : CGFloat = 100
btnSignIn = UIButton(frame: CGRectMake(0,0,btnSize,btnSize))
btnSignIn.center = view.center
btnSignIn.setImage(UIImage(named: "google_logo.png"), forState: UIControlState.Normal)
btnSignIn.addTarget(self, action: #selector(btnSignInPressed), forControlEvents: UIControlEvents.TouchUpInside)
//Circular button
btnSignIn.layer.cornerRadius = btnSize/2
btnSignIn.layer.masksToBounds = true
btnSignIn.layer.borderColor = UIColor.blackColor().CGColor
btnSignIn.layer.borderWidth = 2
view.addSubview(btnSignIn)
...
}
func btnSignInPressed() {
GIDSignIn.sharedInstance().signIn()
}
Related Information:
Facebook SDK and Swift - Create a custom login button programmatically
No comments:
Post a Comment