-2

There is a similar question already on here but it is in objective C. The answer in objective C is apparently:

[self.textView.layer setCornerRadius:10.0f];

I've tried translating this into Swift a few different ways. I'm guessing I want something like this (or maybe there is now a completely different way of doing it given that the obj-c question was posted way back in 2012):

consoleTextView.layer.setCornerRadius(10)

I can't see an option for it in the attributes inspector on xcode either. Maybe it's the NSScrollView that needs changing, I don't know. Hopefully someone with more experience in swift/xcode can help me out.

EDIT- As requested, how the consoleTextView is created:

consoleTextView = consoleScrollView.documentView as? NSTextView

EDIT- Picture of scroll/textView, it's the grey box at the bottom. It's used as a terminal-like window.

enter image description here

SuperHanz98
  • 2,090
  • 2
  • 16
  • 33
  • Can you please add the code, How `consoleTextView` is created ? – Vicky_Vignesh Jul 11 '19 at 10:12
  • Which corners should be rounded, the corners of the text view or the corners of the scroll view? Did you try to round the corners of the scroll view? Is `[self.textView.layer setCornerRadius:10.0f];` copied from an iOS question? – Willeke Jul 11 '19 at 10:38
  • @Willeke My textView and scrollView look like one element. I'll edit to include a picture. I'm not sure which needs rounding, I'm new to swift and xcode so I'm sort of hacking my way through a project. – SuperHanz98 Jul 11 '19 at 11:47
  • Take a look at the view hierarchy (Show Document Outline). The text view is inside a clip view inside the scroll view. – Willeke Jul 11 '19 at 12:29

1 Answers1

1

I managed to solve my problem:

consoleScrollView.wantsLayer = true
consoleScrollView.layer?.cornerRadius = 10

That works ^

You could also do the same with the TextView but you will be left with the square outline of the ScrollView behind it, so if you're trying to achieve the same thing as me you'll have to do it with the ScrollView as well anyway.

E_net4
  • 27,810
  • 13
  • 101
  • 139
SuperHanz98
  • 2,090
  • 2
  • 16
  • 33