我有一段代码可以使用Swift在我的iOS应用程序中添加类似Facebook的按钮。现在我想改变按钮的大小。我试着把100改成其他的,例如160。但纽扣的大小不变。我在其中一个线程中读到,如果我想更改页面大小,应该使用FBSDKLikeButton而不是FBSDKLikeControl,然后我注意到我将失去显示计数器的机会,该计数器显示有多少人已经喜欢我的页面(即likeButton.likeecontrolstyle=FBSDKLikeControlStyle.BoxCount不再适用)。那么,有办法解决这个问题吗?我可以改变我的按钮大小而不失去显示框计数的能力吗?另外,如果我想使用FBSDKLikeControl,如何更改我的facebook类按钮的图像?

import UIKit
    import Parse
    import Social

    class NewsPageViewController: UIViewController {
        override func viewDidLoad() {
            super.viewDidLoad()
            likeButton()
        }
        func likeButton() {
            var likeButton:FBSDKLikeControl = FBSDKLikeControl()
            likeButton.objectID = "https://www.facebook.com/JCVDonline/?fref=ts"
            likeButton.likeControlStyle = FBSDKLikeControlStyle.BoxCount
            likeButton.frame = CGRectMake(16,20, 100, 50)
            self.view.addSubview(likeButton)
        }

}

最佳答案

您可以使用.transformUIButton属性,如下所示:

likeButton.transform = CGAffineTransformMakeScale(2, 2) //doubles the button's size

请注意,这可能会降低按钮的图像质量。如果图像是矢量,则可能不会发生这种情况。去试试吧!;)
希望这有帮助

关于ios - 如何更改按钮大小和图像之类的Facebook?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34303319/

10-14 20:09
查看更多