作者:Sophie-wyq_661 | 来源:互联网 | 2023-05-18 22:49
IhaveaproblemplacingatextViewatspecifiedcentersxandycoordinates.Firstly,Itriedtos
I have a problem placing a textView at specified center's x and y coordinates. Firstly, I tried to set the text in the textView, and to move the view with the width and the height of the view from this link.
将textView放在指定中心的x和y坐标上时遇到问题。首先,我尝试在textView中设置文本,并使用此链接移动视图的宽度和高度。
But it doesn't work, and I'd like to try something else. I'd like to know if there is a method to get the size which a specified text will take in my textView? I mean, I know the text and the textSize, how can I get the width and the height my textView will take?
但它不起作用,我想尝试别的东西。我想知道是否有一种方法可以获得指定文本在textView中的大小?我的意思是,我知道文本和textSize,我如何获得textView将采用的宽度和高度?
Something like the method (NSString)sizeWithFont;
for those who know iPhone dev.
像方法(NSString)sizeWithFont;对于那些了解iPhone开发者的人。
3 个解决方案