After converting code to latest swift 3.0 I am shown this error.
Also tell me solution for CGSize = CGSizeMake(0,0)
static var frameAtStartOfPan: CGRect = CGRectZero
static var startPointOfPan: CGPoint = CGPointZero
Which is also unavailable.
If you want to use them as in swift 2, you can use these funcs:
For CGRectMake:
For CGPointMake:
For CGSizeMake:
Just put them outside any class and it should work. (Works for me at least)
You can use this with replacement of CGRectZero
The structures as well as all other symbols in Core Graphics and other APIs have become cleaner and also include parameter names. https://developer.apple.com/reference/coregraphics#symbols
CGPoint Example:
CGVector Example:
CGSize Example:
CGRect Example:
Apple Blog
Swift syntax and API renaming changes in Swift 3 make the language feel more natural, and provide an even more Swift-y experience when calling Cocoa frameworks. Popular frameworks Core Graphics and Grand Central Dispatch have new, much cleaner interfaces in Swift.
In Swift 4 it works like below
Quick fix for CGRectMake , CGPointMake, CGSizeMake in Swift3 & iOS10
Add these extensions :
Then go to "Find and Replace in Workspace" Find CGRectMake , CGPointMake, CGSizeMake and Replace them with CGRect , CGPoint, CGSize
These steps might save all the time as Xcode right now doesn't give us quick conversion from Swift 2+ to Swift 3
In Swift 3, you can simply use
CGPoint.zero
orCGRect.zero
in place ofCGRectZero
orCGPointZero
.However, in Swift 4,
CGRect.zero
and'CGPoint.zero'
will work