如何动态调整NSTextField的大小? [英] How to resize NSTextField dynamically?

查看:342
本文介绍了如何动态调整NSTextField的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望NSTextField随用户类型而变大,而按Backspace等时变小。

I want an NSTextField to get bigger as the user types, and smaller as backspace is pressed etc.

我唯一发现的是[textField sizeToFit]但这不能动态运行,只是调整大小而已。是否有财产或我需要设置的东西?

The only thing I've found is [textField sizeToFit] but that doesn't run dynamically, it's just a one off resizing. Is there a property or something I need to set?

p.s。我只需要水平调整大小(单行文本)即可。

p.s. I only need it to resize horizontally (single line text).

推荐答案

在实现

- (void)controlTextDidChange:(NSNotification *)aNotification

每次调用该代表时,都会根据您上面的想法调整控件的大小。

Every time the delegate gets called resize the control per your idea above.

这篇关于如何动态调整NSTextField的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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