2017-05-14 17 views
0

NSComboBox에는 필자가 필요로하는 기능이 없기 때문에 내 자신의 comboBox를 작성하려고합니다."메인"스토리 보드에는 그림자가 그려지지만 다른 스토리 보드에는 그려지지 않습니다.

그래서 NSTextField를 서브 클래 싱하고 textinput을 모니터하고 stringValue에 따라 TableView가 데이터를 가져옵니다.

그래서 TableView를 표시해야 할 때 TextFields 수퍼 뷰가 NSScrollView를 추가하고 높이를 조정합니다. 모두 잘 작동합니다.

DropShadow는 그리 좋지 않습니다.

그래서 main.Storyboard에 새 Xcode-Project를 만들고 NSTextField를 추가하고 클래스를 내 하위 클래스로 변경합니다. 텍스트를 입력하자마자 TableView가 나타나고 dropShadow가 있습니다.

다음으로 새로운 스토리 보드를 만들고 새 WindowController를 추가하고 main.Storyboard와 같은 단계를 수행합니다. NSTextField를 추가하고 클래스를 내 서브 클래스로 변경합니다. 이제 main.Storyboard에 Button을 추가합니다.이 Storyboard에는 새로운 Storyboard를 표시하는 작업이 있습니다.

새로운 스토리 보드에서는 textfield 및 tableView가 TableView/ScrollView에 그림자가없는 것을 제외하고는 예상대로 작동합니다.

Generals 탭의 MainInterface를 새로운 Storyboard로 변경해도 TableView의 DropShadow가 변경되지 않습니다.

두 스토리 보드에 대한 IB의 설정이 동일하게 보입니다.

그래서 어떤 문제를 해결할 수 있을까요? 여기

가있는 ScrollView를 추가하고 표시하기위한 코드입니다 빠른 테스트 후

self.scrollView = NSScrollView(frame: NSRect.zero) 
self.scrollView!.documentView = self.tableView 
self.scrollView!.translatesAutoresizingMaskIntoConstraints = false 
self.scrollViewHeightConstraint = NSLayoutConstraint(item: self.scrollView!, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1, constant: 100) 
let topConstraint = NSLayoutConstraint(item: self.scrollView!, attribute: NSLayoutAttribute.top, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.bottom, multiplier: 1, constant: 0) 
let widthConstraint = NSLayoutConstraint(item: self.scrollView!, attribute: NSLayoutAttribute.width, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.width, multiplier: 1, constant: 0) 
let leadinghConstraint = NSLayoutConstraint(item: self.scrollView!, attribute: NSLayoutAttribute.leading, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.leading, multiplier: 1, constant: 0) 
superview.addSubview(self.scrollView!) 
superview.addConstraints([self.scrollViewHeightConstraint!,topConstraint,widthConstraint,leadinghConstraint]) 

let dropShadow = NSShadow() 
dropShadow.shadowColor = NSColor.darkGray 
dropShadow.shadowOffset = NSMakeSize(0, 10.0) 
dropShadow.shadowBlurRadius = 3.0 

self.scrollView!.wantsLayer = true 
self.scrollView!.shadow = dropShadow 

답변

1

... 나는 "문제"를 발견했다. 새로운 ViewControllers를 들어

내가

self.view.wantsLayer = true 
을 설정했다보기