HomeiOS Developmentios - Why UIView() background not apply? (programmatically)

ios – Why UIView() background not apply? (programmatically)


I am attempting to load uiView. And this view ought to have 50 factors distance from proper under label. However simulator exhibits extra little distance.
So I attempted to set background colour of uiView to verify how this view occupy, however it’s not working? what’s the essential downside of my code?

right here is display screen pictures and codes

personal let helpLabelView: UIView = {
        let container = UIView()
        let label1 = UILabel(body: CGRect(x: 0, y: 0, width: 300, peak: 20))
        label1.textual content = "비밀번호를 설정해주세요."
        label1.font = UIFont(identify: "Pretendard-Common", dimension: 15)
        label1.backgroundColor = .cyan
        
        let label2 = UILabel(body: CGRect(x: 0, y: 20, width: 300, peak: 20))
        label2.textual content = "(영어 대소문자, 숫자, 특수문자 각 1개 이상 사용)"
        label2.font = UIFont(identify: "Pretendard-Common", dimension: 15)
        label2.backgroundColor = .inexperienced
        
        container.addSubview(label1)
        container.addSubview(label2)
        
        container.backgroundColor = .brown
        
        return container
    }()
view.addSubview(helpLabelView)
helpLabelView.translatesAutoresizingMaskIntoConstraints = false
pwLabel.bottomAnchor.constraint(equalTo: pwField.topAnchor, fixed: -11),
            pwLabel.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor, fixed: 20),
            helpLabelView.bottomAnchor.constraint(equalTo: pwLabel.topAnchor, fixed: -50),
            helpLabelView.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor, fixed: 20),

pwLabel is close by under label of HelpLabelView
all view is lively
enter image description here

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments