objective-c - 绘制圆角 NSTextFieldCell

标签 objective-c cocoa nstextfieldcell

我的 NSTextFieldCell 代码是:

- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
    // Drawing code here.
    NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:[NSColor lightGrayColor] endingColor:[NSColor grayColor]];
    [gradient drawInRect:cellFrame angle:90];
    [[self title] drawInRect:cellFrame withAttributes:nil];

}

我想让 NSTextFieldCell 具有圆角......我该怎么做?

最佳答案

使用NSView的layer属性,可以为其设置一个角半径。

关于objective-c - 绘制圆角 NSTextFieldCell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1938925/

相关文章:

objective-c - NSTextFieldCell 标准文本绘制位置

ios - 删除 NSAttributedString 属性

objective-c - 使用 BradLarson/GPUImage 的图像过滤效果 ** 问题

ios - locationManager didExitRegion 或 locationManager didEnterRegion 从未调用

objective-c - 使用 NSUserNotification 激活 NSWindow

cocoa - 来自枚举值的 NSString

swift - 在 MacOS 应用程序的 NSTextFieldCell (Swift 3) 中自动调整文本大小

c# - Objective-C 等效于 C# 中的 'as' 运算符

objective-c - 操作系统 : How to detect if Mission Control is running?