Swift3-CGRectMake在Xcode8上'CGRectMake' is unavailable in Swift
2017-01-11 16:33
423 查看
使用Xcode8创建UILabel并给出一个坐标时,这时报错提示:'CGRectMake' is unavailable in Swift,在网上找了很多创建label的代码,之前一直使用的都是CGRectMake方法,但是在此错误是CGRectMake是不可用的,因此只能自力更生。
首先查看了一下frame,发现其参数改为了CGRect,接着往下一级一级的找,它由两个结构体CGPoint、CGSize组成,分别查看一下两个结构体属性即可知道如何修改。在此警告⚠️广大Swift开发者,目前swift依然不是很稳定,毕竟苹果自2010年开始研发Swift,到2014年不足4年就问世了,也在不断的修改更新中,最新文档还是去查阅官方文档比较靠谱。语法有错误也是很正常的,遇到错误时不要慌张,查阅一下资料或者自己潜心研究一下,这样记忆才深刻吗。
UIView(frame:CGRect(x:100,y:100,width:50,height:50))或者如下:
首先查看了一下frame,发现其参数改为了CGRect,接着往下一级一级的找,它由两个结构体CGPoint、CGSize组成,分别查看一下两个结构体属性即可知道如何修改。在此警告⚠️广大Swift开发者,目前swift依然不是很稳定,毕竟苹果自2010年开始研发Swift,到2014年不足4年就问世了,也在不断的修改更新中,最新文档还是去查阅官方文档比较靠谱。语法有错误也是很正常的,遇到错误时不要慌张,查阅一下资料或者自己潜心研究一下,这样记忆才深刻吗。
UIView(frame:CGRect(x:100,y:100,width:50,height:50))或者如下:
let testLabel = UILabel(frame:CGRect(origin: CGPoint(x:100,y:100),size: CGSize(width:200,height:40)))
相关文章推荐
- Swift之Xcode8的'CGRectMake' is unavailable in Swift
- Xcode8使用出现 Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/P
- Xcode8 Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platfo
- object_setInstanceVariable is unavailable: not available in automatic reference counting mode
- swift一次 Attempt to present on whose view is not in the window hierarchy的解决方法
- xcode 中遇到“release is unavailable in automatic reference counting mode”的解决方法
- IOS swift使用webView加载网页上传文件报错:whose view is not in the window hierarchy!
- swift一次 Attempt to present on whose view is not in the window hierarchy的解决方法
- objc[322] Class _NSSwiftEnumeratorBase is implemented in both- 问题解决办法
- Swift - whose view is not in the window hierarchy 问题解决方法
- Swift - whose view is not in the window hierarchy 问题解决方法
- The use of Swift 3 @objc inference in Swift 4 mode is deprecated
- 关于NSAutoreleasePool' is unavailable: not available in automatic reference counting mode的解决方法 .
- Error running Tomcat 7: Address localhost:1099 is already in use
- 解决Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future:
- Service 'china' of type 'MapServer' does not exist or is inaccessible
- Error:(2) Error: "app_name" is not translated in "en" (English), "zh" (Chine
- UserWarning: The installed version of numexpr 2.4 is not supported in pandas and will be not be used
- NameValuePair is deprecated in API 22
- Error: URL Is In the Internet Zone