我想在NSComboBox中显示一个搜索图标作为占位符,就像在搜索框中一样:
通过继承NSComboBox可以轻松完成吗?
答案 0 :(得分:0)
我建议您使用NSTextField和NSImageView将NSView子类化。像一个
NSView
|
|-NSImageView
|
|-NSComboBox
这个班级将是NSTextFieldDelegate
- 响应者:
- (void)controlTextDidBeginEditing:(NSNotification *)notification
{
// change lens image view position (for example with layout constraint constant change animated)
// change text field horizontal text alignment to Left
}
- (void)controlTextDidEndEditing:(NSNotification *)notification
{
// change text field horizontal text alignment to center
// change lens image view position to default
}