【问题标题】:Drawing a rounded cornered NSTextFieldCell绘制圆角 NSTextFieldCell
【发布时间】:2009-12-21 08:44:28
【问题描述】:

我的 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 有圆角.... 我该怎么做?

【问题讨论】:

    标签: objective-c cocoa nstextfieldcell


    【解决方案1】:

    使用 NSView 的 layer 属性,可以设置圆角半径。

    【讨论】:

    • 如何设置圆角半径?
    • controlView.layer.cornerRadius = 0.5;