Cannot change the height of Login Button in FBSDKLoginKit?

后端 未结 12 1632
刺人心
刺人心 2021-02-05 09:19

I am using FBSDKLoginKit in iOS with Swift.

Up until recently it has been working perfectly, however I now cannot override the height of my button in the St

12条回答
  •  孤街浪徒
    2021-02-05 09:38

    This little autoclosure in Swift 4.0 also works perfectly if you have no reason to remove the constraint, just override it.

    let facebookLoginButton = FBSDKLoginButton()
    if let constraint = facebookLoginButton.constraints.first(where: { (constraint) -> Bool in
        return constraint.firstAttribute == .height
    }) {
        constraint.constant = 40.0
    }
    

    Or if you hate let statements:

    let facebookLoginButton = FBSDKLoginButton()
    facebookLoginButton.constraints.first(where: { (constraint) -> Bool in
        return constraint.firstAttribute == .height
    })?.constant = 40.0
    

提交回复
热议问题