티스토리 뷰

나는 위 쪽에 테두리를 추가하고 싶었다.

func addTopBorder(with color: UIColor?, andWidth borderWidth: CGFloat) {
    let border = UIView()
    border.backgroundColor = color
    border.autoresizingMask = [.flexibleWidth, .flexibleBottomMargin]
    border.frame = CGRect(x: 0, y: 0, width: inputTextField.frame.width, height: borderWidth)
    inputTextField.addSubview(border)
}

이렇게 설정하고

addTopBorder(with: UIColor.black, andWidth: CGFloat(0.5))

를 통해 호출했다.

 

출처: https://stackoverflow.com/questions/17355280/how-to-add-a-border-just-on-the-top-side-of-a-uiview/29033559#29033559

댓글