When I created CGRect in Objective-c and I didn't want to set each value, I created in this way:
(CGRect){CGPointMake(0, 0), [UIScreen mainScreen].bounds.size}
Do you know a similar way in swift?
When I created CGRect in Objective-c and I didn't want to set each value, I created in this way:
(CGRect){CGPointMake(0, 0), [UIScreen mainScreen].bounds.size}
Do you know a similar way in swift?
Swift adds a special initializer to CGRect
that does just that.
let rect = CGRect(
origin: CGPoint(x: 0, y: 0),
size: UIScreen.mainScreen().bounds.size
)
For Swift 3.0 you would do this...
let rect = CGRect(
origin: CGPoint(x: 0, y: 0),
size: UIScreen.main.bounds.size
)
Another way for 0,0
let rect = CGRect(
origin: CGPointZero,
size: UIScreen.main.bounds.size
)
© 2022 - 2024 — McMap. All rights reserved.