无法更改FBSDKLoginKit中登录按钮的高度? [英] Cannot change the height of Login Button in FBSDKLoginKit?

查看:302
本文介绍了无法更改FBSDKLoginKit中登录按钮的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iOS中使用Swift时使用 FBSDKLoginKit

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 Storyboard?

由于某种原因,按钮的高度现在要小得多。我已经尝试为按钮设置高度限制,将按钮放在堆栈视图中并设置为按比例填充,甚至覆盖SDK中的按钮高度,没有运气。

The height of the button is now much smaller for some reason. I have tried setting height constraints for the button, putting the button in a stack view and set to fill proportionally and even override the button height in the SDK with no luck.

如果我将按钮更改为正常 UIButton ,则布局约束可以正常工作。

If I change the button to a normal UIButton the layout constraints work perfectly.

这是按钮的样子当我运行应用程序时。

This is what the button looks like when I run the app.

这就是我希望按钮看起来的样子 - 大小明智。

This is how I would like the button to look - size wise.

推荐答案

我也遇到过这个问题。其原因在 4.18.0 4.19.0 升级指南

I've also run into this problem. The reason for this is explained in the 4.18.0 to 4.19.0 upgrade guide:


FBSDKLoginButton 用户界面在4.19.0中已更改。该按钮现在显示继续使用Facebook,而不是使用Facebook登录。按钮颜色从#3B5998更改为#4267B2。 由于在较大的Facebook徽标周围使用较小的字体大小和填充,按钮高度现在固定为28。

The FBSDKLoginButton UI has changed in 4.19.0. Instead of "Log in with Facebook", the button now displays "Continue with Facebook". The button color is changed to #4267B2 from #3B5998. The button height is now fixed at 28 due to use of smaller font size and paddings around a larger Facebook logo.

到目前为止,我发现的唯一解决方法是将SDK版本降级为 4.18.0 (它完成了我想知道。

The only workaround I found so far is to downgrade the SDK version to 4.18.0 (it did the job for me).

FB可能会在未来的SDK更新中解决这个问题(......他们为很多人创建的)。

It is possible that FB will address this issue (...that they've created for many people) in one of the future updates to the SDK.

为了获得更持久的解决方案,我们可以看到导致此,在GitHub 的具体变化。我发现最可疑的更改始于 line 194

Towards a more permanent solution, we can see the specific changes that caused this, on GitHub. The change I find most suspicious starts on line 194:

[self addConstraint:[NSLayoutConstraint constraintWithItem:self
                                                 attribute:NSLayoutAttributeHeight
                                                 relatedBy:NSLayoutRelationEqual
                                                    toItem:nil
                                                 attribute:NSLayoutAttributeNotAnAttribute
                                                multiplier:1
                                                  constant:28]];

如果删除/禁用上述约束,则可以帮助扭转这种情况。它应该看起来大致相似(在撰写本文时我手边还没有IDE):

If the above constraint is removed/disabled, it could help reverse the situation. It should look approximately like this (I don't have an IDE at hand at the time of writing):

// Obtain all constraints for the button:
let layoutConstraintsArr = fbLoginButton.constraints
// Iterate over array and test constraints until we find the correct one:
for lc in layoutConstraintsArr { // or attribute is NSLayoutAttributeHeight etc.
   if ( lc.constant == 28 ){
     // Then disable it...
     lc.active = false
     break
   }
}

当我有机会测试上述内容或者我找到更好的解决方案时,我'将更新答案。

When I get a chance to test the above or if I find a better solution, I'll update the answer.

这篇关于无法更改FBSDKLoginKit中登录按钮的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆