Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 如何自定义NSSegmentedControl?_Swift_Macos_Cocoa_Nssegmentedcontrol - Fatal编程技术网

Swift 如何自定义NSSegmentedControl?

Swift 如何自定义NSSegmentedControl?,swift,macos,cocoa,nssegmentedcontrol,Swift,Macos,Cocoa,Nssegmentedcontrol,你知道我如何获得NSSegmentedControl/NSSegmentedControlCell子类的控件吗 我曾试图覆盖NSSegmentedControlCell中的一些方法,但我甚至无法获得我想要的 override func drawSegment(segment: Int, inFrame frame: NSRect, withView controlView: NSView) { let bez = NSBezierPath(roundedRect: fram

你知道我如何获得NSSegmentedControl/NSSegmentedControlCell子类的控件吗

我曾试图覆盖NSSegmentedControlCell中的一些方法,但我甚至无法获得我想要的

  override func drawSegment(segment: Int, inFrame frame: NSRect, withView controlView: NSView) {

        let bez = NSBezierPath(roundedRect: frame, xRadius: 3, yRadius: 3)
        NSColor.lightGrayColor().set()
        bez.stroke()
        if self.selectedSegment != segment {
            bez.fill()
    }
    //super.drawSegment(segment, inFrame: frame, withView: controlView)
}

override func drawInteriorWithFrame(cellFrame: NSRect, inView controlView: NSView) {
    //
}
drawInteriorWithFrame应该允许我按照自己的意愿绘制背景(只有清晰的颜色,带边框),但它仍然有默认的lightGrayColor

谢谢