-4

I had a bug when I updated to Swift 3.0. For some reason Swift 3.0 doesn't support CGSizeMake. My code looks like this:

self.scrollView.contentSize = CGSizeMake(self.view.frame.width*2, 
self.view.frame.size.height)

What could be some alternatives for CGSizeMake in my case? Please help!

pacification
  • 5,838
  • 4
  • 29
  • 51
  • just use `CGSize(widht: ,height:)` – Mukesh Jan 25 '18 at 11:14
  • [CGSize](https://developer.apple.com/documentation/coregraphics/cgsize) has `init(width: CGFloat, height: CGFloat)`, etc. – pacification Jan 25 '18 at 11:14
  • You can find [this thread](https://stackoverflow.com/q/37946990/6541007) searching with "What is an alternative for CGSizeMake in Swift 3.0". – OOPer Jan 25 '18 at 11:15
  • Put “CGSize” into google. The first result is the documentation. It gives all possible way to initialise CGSize and everything else you can do with it. https://developer.apple.com/documentation/coregraphics/cgsize Always check the docs. – Fogmeister Jan 25 '18 at 11:16
  • 2
    @Fogmeister In Xcode shorter and faster: Press ⇧⌘0 and type `CGSize` – vadian Jan 25 '18 at 11:18
  • @vadian ah! I use Dash so didn’t know about that one. Will have to give that a go myself. :-) – Fogmeister Jan 25 '18 at 11:19
  • Another hint if you are using Xcode: Just type `CGSize(` and Xcode will show you the available choices. Double click on one of the ones with `width:` and `height:` and then type in the width value and then and type in the height value. Try it. It is very useful. – vacawama Jan 25 '18 at 15:36

1 Answers1

5

Please use

CGSize(width: <CGFloat>, height: <CGFloat>)
Ashis Laha
  • 2,176
  • 3
  • 16
  • 17