我已成功将我的自定义FB登录到我的代码中,当我运行我的模拟器时它会显示/工作,但是,我想在其中实现我的自定义设计。有什么方法可以从我的代码中移动它并将其显示为Storyboard上的按钮以添加所述自定义设计。
以下是我已编写的代码
导入UIKit 导入Firebase 导入FBSDKLoginKit
class chooseLogInOrSignUpViewController:UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
//add our custom FB log in here
let customFBButton = UIButton(type: .system)
customFBButton.backgroundColor = .blue
customFBButton.frame = CGRect(x: 16, y:50, width: view.frame.width - 32, height: 50)
customFBButton.setTitle("Connect with Facebook", for: .normal)
customFBButton.setTitleColor(.white, for: .normal)
view.addSubview(customFBButton)
customFBButton.addTarget(self, action: #selector(handleCustomFBLogin), for: .touchUpInside)
}
func handleCustomFBLogin() {
FBSDKLoginManager().logIn(withReadPermissions: ["email", "public_profile"], from: self)
{ (result,err) in
if err != nil {
print("Connect with Facebook failed", err)
return
}
print(result?.token.tokenString)
}
}
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "usersVC")
}
答案 0 :(得分:0)
IBDesignable / IBInspectable
这些有助于制作自定义控件,并允许在“界面”构建器中实时预览设计。
可能有帮助:
答案 1 :(得分:0)
你做不到。您无法在故事板中查看自定义视图。故事板仅呈现Apple实施的某些UIkit视图。
您可以使用自定义视图来帮助定位您的Facebook登录信息并使其成为facebook登录信息的子类。但你什么也看不见