Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
¿Cómo hago que la sombra de botón funcione con Swift 4.2?

Estoy tratando de hacer que mi botón procese una sombra en Swift 4.2

He seguido otros ejemplos en vano. ¿Qué me estoy perdiendo?

 import UIKit class ViewController: UIViewController { @IBOutlet weak var btnHi: UIButton! // Standard button tweeked in view controller @IBOutlet weak var btnNext: NextButton! // My custom button via class override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. btnHi.layer.cornerRadius = btnHi.frame.height / 2 btnHi.layer.borderWidth = 3.0 btnHi.layer.borderColor = UIColor.darkGray.cgColor btnHi.layer.shadowColor = UIColor.black.cgColor btnHi.layer.shadowOffset = CGSize(width: 0.0, height: 6.0) btnHi.layer.shadowRadius = 8 btnHi.layer.opacity = 0.5 // btnHi.clipsToBounds = true // btnHi.layer.masksToBounds = false } @IBAction func btnNext(_ sender: Any) { btnNext.setupShakeButton() } }

debería ver una sombra paralela para el botón, en lugar de eso, no obtengo sombra. ingrese la descripción de la imagen aquí

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Te falta shadowOpacity que es cero de forma predeterminada. Probablemente no debería usar la opacity porque eso hace que todo el botón sea semitransparente.

 btnHi.layer.shadowColor = UIColor.black.cgColor btnHi.layer.shadowOffset = CGSize(width: 0.0, height: 6.0) btnHi.layer.shadowRadius = 8 btnHi.layer.shadowOpacity = 0.5

También tenga en cuenta que el recorte debe estar desactivado:

 btnHi.layer.masksToBounds = false
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!