Drawing a rounded cornered NSTextFieldCell

╄→尐↘猪︶ㄣ 提交于 2019-12-20 03:55:14

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/1938925/drawing-a-rounded-cornered-nstextfieldcell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!