使用 Value With Pattern 绑定时如何格式化浮点小数?
我有一个 NSTextField,它通过 Interface Builder 通过“Value with Pattern”字段绑定到一个浮点值。默认显示模式是 %{value1}@
有什么方法可以修改该行以将输出格式设置为小数点后两位?或者只能通过代码实现?
I have an NSTextField, which is bound to a float value through Interface Builder via "Value with Pattern" field. The default display pattern is %{value1}@
Is there any way I can modify that line to have my output formatted to 2 decimal places? Or is that only possible through code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也一直在尝试这样做。您可以将数字格式化程序从对象库拖到要格式化的对象顶部。格式化程序的属性页之一允许您从预定义格式列表中进行选择,或者选择自定义并创建您自己的格式。
I've just been trying to do this, as well. You can drag a Number Formatter from the object library on top of the object you want to format. One of the property pages for the formatter allows you to choose from a list of predefined formats, or choose custom and make your own.