Customizing Parse Login in Swift

983 views Asked by At

I'm using Parse for the first time and have got the basic functionality working, but can't seem to customize the login form. Basically, I just want to change the title (Currently it is "Parse") and remove the "x" close button at the top left hand corner. The code I'm using is below, any help appreciated

override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)

    if (PFUser.currentUser() == nil) {

        var logInViewController = PFLogInViewController()
        logInViewController.title = "New Title"

        logInViewController.delegate = self

        var signUpViewController = PFSignUpViewController()

        signUpViewController.delegate = self

        logInViewController.signUpController = signUpViewController

        self.presentViewController(logInViewController, animated: true, completion: nil)

    }else {

        self.fetchAllObjectsFromLocalDatastore()
        self.fetchAllObjects()

    }

}
1

There are 1 answers

2
Michael Lee On

Next time, it would be better if you could take a closer look at the documentation; both of these things are explicitly covered in the Parse docs.

These are the UI elements given by the Parse login template

To select which elements you want to toggle, simply configure and pick the fields element of the login controller.

logInController.fields = (PFLogInFields.UsernameAndPassword
                       | PFLogInFields.LogInButton
                       | PFLogInFields.SignUpButton
                       | PFLogInFields.PasswordForgotten
                       | PFLogInFields.DismissButton)

In this case, you need to remove the DismissButton field, so just remove that.

To change the Parse logo, you need to subclass PFLogInViewController:

class MyLogInViewController : PFLogInViewController {
  override func viewDidLoad() {
    super.viewDidLoad()
    self.view.backgroundColor = UIColor.darkGrayColor()
    let logoView = UIImageView(image: UIImage(named:"logo.png"))
    self.logInView.logo = logoView
  }
}

and then assign it to the signUpController

let logInController = MyLogInViewController()
logInController.signUpController = MySignUpViewController()
self.presentViewController(logInController, animated: true, completion: nil)

For further customization, take a look at the Parse docs.