How to Convert NSString into CGPoint in iPhone

匿名 (未验证) 提交于 2019-12-03 08:35:02

问题:

I am getting the values from UITextfield into NSString , need to convert the values of NSString into CGPoint, Suppose if i enter 6,5 into textfield it should covert it into CGPoint.

回答1:

See CGPointFromString (documentation in link). The string has to be in the format {x,y} so you would need to add those to the user input yourself:

CGPoint myPoint = CGPointFromString([NSString stringWithFormat:@"{%@}",textField.text]);

Will return CGPointZero if the string is invalid.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!