PawelPawel
PawelPawel

Reputation: 77

NSTextView round corners and draw background

For two I've been working on following problem:

I'm supposed to create message chat view which is going to be placed in NSTableView. It has to have color background, rounded corners, custom margins. I tried with NSTextField but with no success. I have desired background and rounded corners but text is not displayed correctly because it starts in the center of the field in case of multiline. Also I tried with NSTextView, which seems to be better solution in this situation, but I couldn't set rounded corners. I tried using [textView.layer setCornerRadius:7.0]; but it gives no effect.

Thanks for any reply!

Upvotes: 4

Views: 2265

Answers (1)

Joe Hallenbeck
Joe Hallenbeck

Reputation: 1450

Add it to Text View property

enter image description here

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

And you can see>

enter image description here

But you Scroll View backgroundColor should be WindowBackgroundcolor

enter image description here

enter image description here

Upvotes: 10

Related Questions