How does one custom resize the iOS login button



I’m having so much trouble getting the login button to resize. I’ve tried to create a frame with CGRect, like so(within viewDidLoad)

let twitterLoginButton = TWTRLogInButton(frame: CGRectMake(0, 0, 200, 50))

Also tried this

let twitterLoginButton = TWTRLogInButton.init(frame: CGRectMake(0, 0, 200, 50))

But no luck.

Also tried to force the button into a parent container and then try to force the button to assume the size of parent like so

let twitterLoginButton = TWTRLogInButton()
let twitterLoginButtonParent = TWTRLogInButton(frame: CGRectMake(0, 0, 200, 50))

let twitterLoginButtonSize = CGSize(width: 200, height: 50)

Is it even possible to resize this button? Supposedly it is a subclass of UIButton, yet none of the methods of UIButton seem to work on it. Thanks.


Hey @RelevantMe

One quick question - do you have AutoLayout set to “Yes” in a Xib file or Storyboard? That would be preventing your changes from taking effect. With AutoLayout set to “No”, I’m able to get this to display (I made it look bad intentionally :)) :

Using: (Obj-C, instead of Swift, but both should work) =;
    [logInButton setFrame:CGRectMake(273, 269, 130, 144)];
    [self.view addSubview:logInButton];


@bonnell Thanks for the response. Unfortunately though, disabling auto layout for the UI in question did not work. The button still stubbornly won’t adhere to any CGRect specifications :frowning:


@bonnell Finally got it to work:) by first initializing the button with loginCompletion before assigning it a frame.

    let twitterLoginButton = TWTRLogInButton(logInCompletion: { session, error in
        if (session != nil) {
            print("signed in as \(session!.userName)");
        } else {
            print("error: \(error!.localizedDescription)");

    twitterLoginButton.frame  = CGRectMake(0, 0, 50, 50)


Thanks for sharing your solution @RelevantMe and happy coding!