绘制圆角NSTextFieldCell [英] Drawing a rounded cornered NSTextFieldCell

查看:166
本文介绍了绘制圆角NSTextFieldCell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码为我的NSTextFieldCell是:

   - (void)drawInteriorWithFrame:(NSRect)cellFrame inView: controlView {
//这里绘制代码。
NSGradient * gradient = [[NSGradient alloc] initWithStartingColor:[NSColor lightGrayColor] endingColor:[NSColor grayColor]];
[gradient drawInRect:cellFrame angle:90];
[[self title] drawInRect:cellFrame withAttributes:nil];

}



我希望NSTextFieldCell具有圆角。 ...

解决方案

使用NSView的图层属性,然后您可以为此设置角半径。


My code for my NSTextFieldCell is:

- (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];

}

I would like to have the NSTextFieldCell to have rounded corners.... how could I do this?

解决方案

Use the layer property of NSView, then you can set a corner radius for this.

这篇关于绘制圆角NSTextFieldCell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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