NSTextField透明背景 [英] NSTextField transparent background

查看:382
本文介绍了NSTextField透明背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建透明 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];

一切看起来不错
我也尝试过 drawsBackground = NO; 你们知道如何解决这个问题吗?

everything looks ok I have also tried with drawsBackground = NO; Do you guys know how to fix this?

推荐答案

我最后使用 CATextLayer 而不是 NSTextField

I ended up using CATextLayer instead NSTextField.

这篇关于NSTextField透明背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆