如何确定UITextfield中文本的长度 [英] How to determine the length of the text in a UITextfield

查看:108
本文介绍了如何确定UITextfield中文本的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITextField,我想从中确定输入文本的宽度。

I have a UITextField from which I'd like to determine the width of the entered text.

bounds属性只有Textfield的大小但不是文本

The bounds property has just the size of the Textfield but not of the text

推荐答案

CGFloat width =  [aTextField.text sizeWithFont:aTextField.font].width;

这篇关于如何确定UITextfield中文本的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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