NSTableView圆角 [英] NSTableView rounded corners

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

问题描述

对于在NSTableView子类中绘制圆角,我重写drawRect方法

For drawing rounded corners in the NSTableView subclass I override the drawRect method

- (void)drawRect:(NSRect)rect{
    NSBezierPath* path = [NSBezierPath bezierPathWithRoundedRect:rect cornerRadius:7.0f];
    [path addClip];
    [super drawRect:selfRect];
}

只要表视图的内容不太大,不显示滚动条。但是当内容变大时,会显示NSScrollView的滚动条,并且圆角边缘消失。

This works as long as the content of the table view is not too big and not showing the scrollers. But when the content gets bigger, the scrollers of the NSScrollView are displayed and the rounded edges disappear.

这是什么提示?

推荐答案

由于表视图包含在滚动视图中,我想你想要的是一个滚动视图,而不是带有圆角的表视图。也许你可以尝试子类化滚动视图。

Since a table view is contained in a scroll view, I guess what you want is a scroll view but not table view with rounded corners. Maybe you can try to subclass the scroll view.

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

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