can someone help me here I am currently getting this error saying that CGRectMake is not available in Swift. I have looked at other answers on this and I am still getting a little confused. Could anyone please write me an exact answer would be much appreciated.
scrollView.frame = CGRect(0, 0, self.view.frame.width, self.view.frame.height)
CGRectMake has been deprecated. The syntax is now just CGRect. I believe the syntax change was introduced in Swift 3.
Notice that the x and y together form a CGPoint, and the width and height form a CGSize. So when you say:
scrollView.frame = CGRect(0, 0, self.view.frame.width, self.view.frame.height)
you are putting the scrollView at the CGPoint (0,0) and giving it the same same CGSize as the width and height of the view (covering the whole view).
Which Swift version are you using? I think you are using Swift 3 and above.
CGRectMake is deprecated after Swift 3. You have to use CGRect instead of CGRectMake.
let scrollView = UIScrollView()
scrollView.frame = CGRect(0,0,self.view.frame.width,self.view.frame.height)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With