7

Using swift xcode 8 getting an error not sure how to get around. CGSizeMake unavailable in swift.

What can you change that to or is there a way around it??

  • 13
    Use `CGSize` constructor, e.g. `CGSize(width: ..., height: ...)`. – Rob Jun 26 '16 at 08:00
  • As an aside, if you use auto layout constraints within the scroll view, you often don't have to manually set the `contentSize`. But when you do, you can set it like above. – Rob Jun 26 '16 at 08:01
  • @Rob I don't think the contentSize participate in autolayout. – kennytm Jun 26 '16 at 08:03
  • @kennytm - No, it does participate. It's one of the beauties of auto layout with scroll views, that you can add the subviews and their constraints, and the content size is updated for you. If anything, it's a source of confusion because with most subviews, the constraint between a view and its subviews dictates their relative frame sizes, whereas constraints between scroll views and their subviews dictate the relationship between the size of the scroll view's `contentSize` and the size of the subviews. See http://stackoverflow.com/a/16471244/1271826. – Rob Jun 26 '16 at 08:09

0 Answers0