Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

402
Vistas
@IBDesignable not rendering UILabel and UITextField texts

I've created a @IBDesignable subclass of UIView

The view has couple of labels and a text field.

When I try to change their value in the storyboard, the changes are not rendered. In constant changes in cornerRadius, borderWidth and borderColor are rendered on the storyboard.

What am I missing?

This is how it looks in storyboard:

enter image description here

This is how it looks in the simulator and how I expect it to look in the storyboard after rendering:

enter image description here

This is the code of the class:

import UIKit

@IBDesignable

class LoginTextField: UIView {


    @IBInspectable var cornerRadius: CGFloat = 0 {
        didSet {
            layer.cornerRadius = cornerRadius
            layer.masksToBounds = cornerRadius > 0
        }
    }
    @IBInspectable var borderWidth: CGFloat = 0 {
        didSet {
            layer.borderWidth = borderWidth
        }
    }
    @IBInspectable var borderColor: UIColor? {
        didSet {
            layer.borderColor = borderColor?.cgColor
        }
    }

    @IBInspectable var title: String = "" {
        didSet {
            titleLabel.text = title
        }
    }

    @IBInspectable var placeholder: String = "" {
        didSet {
            textField.placeholder = placeholder
        }
    }

    @IBInspectable var message: String = "" {
        didSet {
            messageLabel.text = message
        }
    }

    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var textField: UITextField!
    @IBOutlet weak var messageLabel: UILabel!

    @IBOutlet var contentView: UIView!

    override init(frame: CGRect) {

        super.init(frame: frame)
        commonInit()
    }

    override func awakeFromNib() {

        super.awakeFromNib()
    }

    required init?(coder aDecoder: NSCoder) {

        super.init(coder: aDecoder)
        commonInit()
    }

    private func commonInit() {

        let bundle = Bundle.init(for: type(of: self))
        bundle.loadNibNamed("LoginTextField", owner: self, options: nil)
        addSubview(contentView)
        contentView.frame = self.bounds
        contentView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
    }
}

Update: everything started to work all of a sudden enter image description here

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda