2016-10-02 13 views
0

私は自分のアプリにFacebookのログインボタンを持っていますが、左上から画面の中央に移動できません。FBSDKLoginButtonの位置を変更できません

loginButton.center = (self.view?.center)! 

loginButton.frame = CGRect(origin: CGPoint(x: self.frame.midX,y :self.frame.midY), size: CGSize(width: loginButton.frame.width, height: loginButton.frame.height)) 

をどちらも、中央変数の変更、働いたがボタンが左上隅

に残っている誰もがこの問題を解決する方法を知っているん:私が試した ?

私はあなたがこのようなあなたのコードを設定する必要があり、このコード

let loginButton: FBSDKLoginButton = { 
     let button = FBSDKLoginButton() 
     button.readPermissions = ["email"] 
     button.translatesAutoresizingMaskIntoConstraints = false 
    return button 
    }() 
view.addSubview(loginButton) 
+0

を参照してください?ボタンを追加するために使用しているコード行を共有してください。 – DevKyle

+0

せloginButton:FBSDKLoginButton = { LETボタン= FBSDKLoginButton() button.readPermissions = [ "電子メール"] button.translatesAutoresizingMaskIntoConstraints =偽 戻るボタン }() view.addSubview(loginButton) – toiavalle

答えて

1

にボタンを追加している:

let loginButton = FBSDKLoginButton(frame: CGRect(x: 0, y: 0, width: //whatever width you want, height: //whatever height you want)) 
    loginButton.readPermissions = ["email"] 
    loginButton.center = view.center 
    view.addSubview(loginButton) 

には、表示するボタンを追加する方法https://developers.facebook.com/docs/facebook-login/ios#loginkit

関連する問題