2017-02-17 2 views
1

나는 사용자 입력이 6 자 미만의 경우에만 나는 그것을 보여 스위프트스위프트 메이크업 라벨 오버랩 상태 표시 줄

let top_error_rep: UILabel = { 
    let lb = UILabel() 
    lb.text="Password should be at least 6 charachters" 
    lb.textColor = UIColor(r: 230, g: 230, b: 230) 
    lb.backgroundColor = .red 
    return lb; 
}() 

에이 라벨을 가지고있다. 이제 상태 표시 줄이 입력과 겹치는 것을 보여 주면 어떻게 방지 할 수 있습니까?

이것은

+0

어디에서 레이블을 배치 했습니까? –

+0

UIview 상단 @GaneshKumar –

+0

코드 및 스크린 샷 제공 방법 –

답변

1
  1. enter image description here

    같은 설정 라벨의 위치를 ​​보이는 방법이다.

보기의 하위보기에 레이블을 추가 한 후. 다음과 같은 제약 조건을 사용하여 위치를 설정해야합니다.

top_error_rep.topAnchor.constraint(equalTo: self.topAnchor).isActive = true 
top_error_rep.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true 
top_error_rep.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true 
top_error_rep.heightAnchor.constraint(equalToConstant: 20).isActive = true 

또는 다른 방법을 사용할 수 있습니다. 구글 Auto layout programmatically swift

  • 사용자 입력 미만 6 자
  • 경우에만 표시 확인

    How do I check when a UITextField changes?

    이 5 월 당신에게

    편집을하는 데 도움이

    상태 표시 줄을 숨기려면 ViewController에 추가하십시오.

    override func viewDidAppear(_ animated: Bool) { 
        super.viewDidAppear(animated) 
        //Add below line..... 
        UIApplication.shared.isStatusBarHidden = true 
    } 
    
    override func viewWillDisappear(_ animated: Bool) { 
        super.viewWillDisappear(animated) 
        //It will show the status bar again after dismiss 
        UIApplication.shared.isStatusBarHidden = false 
    } 
    
    override var prefersStatusBarHidden: Bool { 
        return true 
    } 
    
    +0

    제약 조건을 추가했습니다.하지만 상태 표시 줄을 겹치게 만하면됩니다. –

    +0

    질문에 대한 오해 때문에 사과드립니다 ... 내 편집 됨 대답 –

    +0

    그 해 주셔서 감사합니다! –