Bordered UITextView

后端 未结 14 2094
一个人的身影
一个人的身影 2020-12-04 10:11

I want to have a thin gray border around a UITextView. I have gone through the Apple documentation but couldn\'t find any property there. Please help.

相关标签:
14条回答
  • 2020-12-04 10:47

    I believe the above answers are for the previous versions of Swift. I Googled a bit and the below code works for Swift 4. Just sharing it for whoever it may benefit.

    self.textViewName.layer.borderColor = UIColor.lightGray.cgColor
    self.textViewName.layer.borderWidth = 1.0
    self.textViewName.layer.cornerRadius = 8
    

    Happy Coding!

    0 讨论(0)
  • 2020-12-04 10:47

    I solved this problem in storyboard by putting a fully disabled UIButton behind the UITextView and making the background color of the UITextView clearColor. This works without requiring extra code or packages.

    0 讨论(0)
提交回复
热议问题