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

399
Views
@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
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!