[英]How to convert NSTextField value to CGFloat
let countY = CGFloat(self.textbox1.stringValue); //NSTextField value= 1024.231234
if let image:CGImage = CGDisplayCreateImage(CGMainDisplayID(), rect: CGRect(x: countX, y: countY, width: 1, height: 1))
{
我得到了错误
表达式类型'@lvalue字符串'不明确,没有更多上下文
CGFloat
没有字符串初始值设定项。
只需从文本字段而不是stringValue
获取doubleValue
let countY = CGFloat(self.textbox1.doubleValue)
if let image = CGDisplayCreateImage(CGMainDisplayID(), rect: CGRect(x: countX, y: countY, width: 1, height: 1)) {
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.