Ios 如何仅将apple徽标图像设置为使用apple按钮登录

Ios 如何仅将apple徽标图像设置为使用apple按钮登录,ios,objective-c,swift,apple-sign-in,sign-in-with-apple,Ios,Objective C,Swift,Apple Sign In,Sign In With Apple,我正在开发一个应用程序,我提供了三个登录选项,如facebook、谷歌和苹果。我需要为所有三个设置相同的设计。我用苹果按钮登录是长方形的,我想知道我能不能改变那个按钮的设计,以及如何改变。我需要使它与苹果公司的标志,而不是文字循环。那么如何将apple徽标图像设置为AuthorizationAppleIDButton。我在下面的链接上读到了苹果的设计,但并没有提到如何将图片设置为按钮。 您需要根据制作自定义按钮。你必须遵循他们的指导方针,以避免审查被拒 您可以从下载苹果设计资源 在应用程序中添加

我正在开发一个应用程序,我提供了三个登录选项,如facebook、谷歌和苹果。我需要为所有三个设置相同的设计。我用苹果按钮登录是长方形的,我想知道我能不能改变那个按钮的设计,以及如何改变。我需要使它与苹果公司的标志,而不是文字循环。那么如何将apple徽标图像设置为AuthorizationAppleIDButton。我在下面的链接上读到了苹果的设计,但并没有提到如何将图片设置为按钮。

您需要根据制作自定义按钮。你必须遵循他们的指导方针,以避免审查被拒

您可以从下载苹果设计资源

在应用程序中添加自定义按钮:

func appleCustomLoginButton() {
   //Sign in with app is only available from iOS 13 onwards
    if #available(iOS 13.0, *) {
        let customAppleLoginBtn = UIButton()
        customAppleLoginBtn.backgroundColor = UIColor.white
        customAppleLoginBtn.setImage(UIImage(named: "appleLogo"), for: .normal)
        customAppleLoginBtn.addTarget(self, action: #selector(actionHandleAppleSignin), for: .touchUpInside)
        view.addSubview(customAppleLoginBtn)

        // Setup Layout Constraints to be in the center of the screen
        customAppleLoginBtn.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.activate([
            customAppleLoginBtn.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
            customAppleLoginBtn.centerYAnchor.constraint(equalTo: self.view.centerYAnchor),
            customAppleLoginBtn.widthAnchor.constraint(equalToConstant: 200),
            customAppleLoginBtn.heightAnchor.constraint(equalToConstant: 40)
            ])
    }
}

@objc func actionHandleAppleSignin() {

    //do something when button is clicked
}

您需要根据定制按钮。你必须遵循他们的指导方针,以避免审查被拒

您可以从下载苹果设计资源

在应用程序中添加自定义按钮:

func appleCustomLoginButton() {
   //Sign in with app is only available from iOS 13 onwards
    if #available(iOS 13.0, *) {
        let customAppleLoginBtn = UIButton()
        customAppleLoginBtn.backgroundColor = UIColor.white
        customAppleLoginBtn.setImage(UIImage(named: "appleLogo"), for: .normal)
        customAppleLoginBtn.addTarget(self, action: #selector(actionHandleAppleSignin), for: .touchUpInside)
        view.addSubview(customAppleLoginBtn)

        // Setup Layout Constraints to be in the center of the screen
        customAppleLoginBtn.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.activate([
            customAppleLoginBtn.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
            customAppleLoginBtn.centerYAnchor.constraint(equalTo: self.view.centerYAnchor),
            customAppleLoginBtn.widthAnchor.constraint(equalToConstant: 200),
            customAppleLoginBtn.heightAnchor.constraint(equalToConstant: 40)
            ])
    }
}

@objc func actionHandleAppleSignin() {

    //do something when button is clicked
}

这很简单。如果您有任何进一步的疑问,请随时询问,谢谢

     //1. setting apple logo
        let appleLogo = UIImage(systemName: "appleLogo.png")!
     //2. create a button
        let button = UIButton()
     //3. setImage with image name
        button.setImage(appleLogo, for: .normal)
     //4. Set image rounded.
        button.layer.cornerRadius = button.frame.height/2
     //5. Setting empty button text
        button.titleLabel?.text = ""

这很简单。如果您有任何进一步的疑问,请随时询问,谢谢

     //1. setting apple logo
        let appleLogo = UIImage(systemName: "appleLogo.png")!
     //2. create a button
        let button = UIButton()
     //3. setImage with image name
        button.setImage(appleLogo, for: .normal)
     //4. Set image rounded.
        button.layer.cornerRadius = button.frame.height/2
     //5. Setting empty button text
        button.titleLabel?.text = ""

请解释一下为什么你认为这是一个正确的解决方案。这对你来说可能很简单,但对其他人来说不是。嘿@koen,你试过我的方法吗。因为这是一个非常简单的方法。我已经写了一些评论以供理解。请解释一下为什么你认为这是一个正确的解决方案。这对你来说可能很简单,但对其他人来说不是。嘿@koen,你试过我的方法吗。因为这是一个非常简单的方法。我已经写了评论以供理解。