foreyez foreyez - 1 year ago 131
Swift Question

How to Create a CGSize in Swift?

How can I create a CGSize in Swift? This is what I have tried so far (but doesn't work):

var s:CGSize = {10,20}
var s:CGSize = CGMakeSize(10,20)

Answer Source

Your first attempt won't work because C structs don't exist in Swift. You need:

var size = CGSize(width: 20, height: 30)


var size = CGSizeMake(20,30)

(Not MakeSize).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download