CGRect.offsetBy Not Working
Asked Answered
T

1

10

How do I rewrite the code below?

self.view.frame = CGRectOffset(self.view.frame, 0, movement)

'Offset' has been replaced by 'offsetby'

When I replaced it with the so called "solution":

self.view.frame = CGRect.offsetby(self.view.frame, 0, movement)

I receive an error:

"Instance member 'offsetBy' cannot be used on type 'CGRect'; did you mean to use a value of this type instead?"

Tabbie answered 12/12, 2017 at 4:11 Comment(2)
Are you working with Xcode 9.x? Swift 4? If so, please define what movement is.Nonunionism
@dfd Xcode: 9.2 & Swift 4Tabbie
O
29

You have to call offsetBy on an instance of a CGRect.

self.view.frame = self.view.frame.offsetBy(dx: 0, dy: movement)
Oyez answered 12/12, 2017 at 4:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.