“Crie o botão com o ícone Swift” Respostas de código

Swift Crie um botão personalizado com o ícone programaticamente

let googleView = UIView()
googleView.layer.backgroundColor = UIColor.white.cgColor
googleView.frame = CGRect(x: 30, y: 100, width: view.bounds.width - 60, height: 50)
googleView.layer.cornerRadius = googleView.frame.height / 2
let googleButton = UIView()
googleButton.frame = CGRect(x: googleView.layer.cornerRadius, y: 0, width: googleView.frame.width - 2 * googleView.layer.cornerRadius, height: 50
let googleImage = UIImageView(image: UIImage(named: "googleLogo"))
googleImage.frame = CGRect(x: 0, y: 10, width: 30, height: 30)
googleButton.addSubview(googleImage)
let googleLabel = UILabel()
googleLabel.frame = CGRect(x: googleImage.frame.maxX, y: 10, width: 1000, height: 30)
googleLabel.text = "   Sign up with Google"
googleLabel.font = UIFont.boldSystemFont(ofSize: 17)
googleLabel.sizeToFit()
googleLabel.center.y = googleImage.center.y
googleButton.addSubview(googleLabel)
googleButton.frame.size.width = googleLabel.frame.maxX
googleButton.center.x = googleView.frame.width / 2
googleView.addSubview(googleButton)
let googleTap = UITapGestureRecognizer(target: self, action: #selector(googleLogin))
googleView.isUserInteractionEnabled = true
googleView.addGestureRecognizer(googleTap)
view.addSubview(googleView)


  [1]: https://i.stack.imgur.com/HaZyU.png
Enthusiastic Echidna

Crie o botão com o ícone Swift

button.setImage(UIImage(systemName: "search"), for: .normal)
N8

Respostas semelhantes a “Crie o botão com o ícone Swift”

Perguntas semelhantes a “Crie o botão com o ícone Swift”

Mais respostas relacionadas para “Crie o botão com o ícone Swift” em Swift

Procure respostas de código populares por idioma

Procurar outros idiomas de código