-2

I implement facebook and google button but I can't set the corner radius for the button here is my code

    @IBOutlet var fb_login_btn: FBSDKLoginButton! 
          fb_login_btn.layer.cornerRadius = 20
    @IBOutlet var google_login_btn: GIDSignInButton!
  google_login_btn.layer.cornerRadius = 20

How can I customize the button in swift3

Cœur
  • 37,241
  • 25
  • 195
  • 267
Agaram
  • 93
  • 2
  • 13
  • 1
    Possible duplicate of [Swift - how to set corner radius of imageView](http://stackoverflow.com/questions/27861383/swift-how-to-set-corner-radius-of-imageview) – xoudini Jan 10 '17 at 12:49
  • how can u say this duplicate i am not asking about FBSDKLoginButton – Agaram Jan 10 '17 at 13:02
  • It doesn't make a difference, they both descend from `UIView` and so have the same layer properties. See [FBSDKButton.h](https://github.com/facebook/facebook-ios-sdk/blob/f7531a838a1ec3308721f335e801ac9f508feee4/FBSDKCoreKit/FBSDKCoreKit/FBSDKButton.h). Google's SDK doesn't appear to be open-source, but the types can be inspected in Xcode. – xoudini Jan 10 '17 at 13:09

1 Answers1

4

You also need to set layer property masksToBounds to true for cornerRadius.

fb_login_btn.layer.cornerRadius = 20
fb_login_btn.layer.masksToBounds = true

google_login_btn.layer.cornerRadius = 20
google_login_btn.layer.masksToBounds = true
Nirav D
  • 71,513
  • 12
  • 161
  • 183