Skip to content

Instantly share code, notes, and snippets.

@gunantosteven
Created May 14, 2020 15:16
Show Gist options
  • Save gunantosteven/da60933890c7afca650a31eb2a1a5136 to your computer and use it in GitHub Desktop.
Save gunantosteven/da60933890c7afca650a31eb2a1a5136 to your computer and use it in GitHub Desktop.
Create Button Auth Facebook FBLoginButton Full Width
class SettingsSignInTableViewCell: UITableViewCell {
@IBOutlet private var viewFBLoginButton: UIView! {
didSet {
// Add tap gesture
let tapViewFBLoginButton = UITapGestureRecognizer(
target: self, action: #selector(SettingsSignInTableViewCell.tapViewFBLoginButton(_:)))
tapViewFBLoginButton.numberOfTapsRequired = 1
viewFBLoginButton.isUserInteractionEnabled = true
viewFBLoginButton.addGestureRecognizer(tapViewFBLoginButton)
}
}
var loginButton = FBLoginButton()
override func awakeFromNib() {
super.awakeFromNib()
var horizontalAdjust: CGFloat = 0
if DeviceType.ISIPHONE6 {
horizontalAdjust = 24
} else if DeviceType.ISIPHONEXORXS {
horizontalAdjust = 16
}
loginButton.delegate = self
loginButton.center = CGPoint(x: viewFBLoginButton.center.x - horizontalAdjust, y: viewFBLoginButton.center.y)
contentView.addSubview(loginButton)
loginButton.permissions = ["public_profile", "email"]
}
@objc func tapViewFBLoginButton(_ recognizer: UITapGestureRecognizer) {
self.loginButton.sendActions(for: .touchUpInside)
}
}
struct DeviceType {
static let ISIPHONE4ORLESS = UIDevice.current.userInterfaceIdiom == .phone && ScreenSize.SCREENMAXLENGTH < 568.0
static let ISIPHONE5 = UIDevice.current.userInterfaceIdiom == .phone && ScreenSize.SCREENMAXLENGTH == 568.0
static let ISIPHONE6 = UIDevice.current.userInterfaceIdiom == .phone && ScreenSize.SCREENMAXLENGTH == 667.0
static let ISIPHONE6P = UIDevice.current.userInterfaceIdiom == .phone && ScreenSize.SCREENMAXLENGTH == 736.0
static let ISIPHONEXORXS = UIDevice.current.userInterfaceIdiom == .phone && ScreenSize.SCREENMAXLENGTH == 812.0
static let ISIPHONEXRORXSMAX = UIDevice.current.userInterfaceIdiom == .phone && ScreenSize.SCREENMAXLENGTH == 896.0
static let ISPAD = UIDevice.current.userInterfaceIdiom == .pad && ScreenSize.SCREENMAXLENGTH == 1_024.0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment