NSTextField transparent background

cocoa, macos, nstextfield

Solution

I ended up using `CATextLayer` instead `NSTextField`.

Problem

I create transparent `NSTextField` ``` self.myTextField = [[NSTextField alloc] initWithFrame:CGRectMake(backgroundView.frame.origin.x + backgroundView.frame.size.width + 20, self.projectTitle.frame.origin.y - 30.0, 100, 20)]; self.myTextField.editable = NO; self.myTextField.bezeled = NO; self.myTextField.drawsBackground = YES; self.myTextField.backgroundColor = [NSColor clearColor]; self.myTextField.selectable = NO; self.myTextField.font = [NSFont fontWithName:@"Helvetica Neue" size:16]; [self addSubview:self.compressingTime]; ``` And as a result text look bad. If I set background color ``` self.myTextField.backgroundColor = [NSColor colorWithCalibratedRed:0.85 green:0.85 blue:0.85 alpha:1.0]; ``` everything looks ok I have also tried with `drawsBackground = NO;` Do you guys know how to fix this?

Original source