CGRectDivide Deprecated in Fast 3

How fast, 3 says it's CGRectDivideout of date, and replacement is divided(atDistance: CGFloat, from fromEdge: CGRectEdge) -> (slice: CGRect, remainder: CGRect).

As I know, CGRectDivideby default I split the source rectangle into two component rectangles. Questions - what to do and what to use to perform the same operation as CGRectDivide using swift 3?

Update 1: Quick Function 2 looks like this:

fileprivate func isLeftPointContainedWithinBezelRect(_ point: CGPoint) -> Bool{
    if let bezelWidth = SlideMenuOptions.leftBezelWidth {
        var leftBezelRect: CGRect = CGRect.zero
        var tempRect: CGRect = CGRect.zero

        CGRectDivide(view.bounds, &leftBezelRect, &tempRect, bezelWidth, CGRectEdge.minXEdge)

        print("------> slidee1")

        return leftBezelRect.contains(point)
    } else {
        return true
    }
}
+4
source share
1 answer

In fast 3, you can write like this.

let rect = CGRect(x: 0, y: 0, width: 50, height: 50)
let (slice, remainder) = rect.divided(atDistance: 5.0, fromEdge: .minXEdge)
print(slice)
print(remainder)

Output

(0.0, 0.0, 5.0, 50.0)
(5.0, 0.0, 45.0, 50.0)

Edit: In your case, it is written as.

(leftBezelRect, tempRect) = view.bounds.divided(atDistance: bezelWidth, fromEdge: .minXEdge)
+12
source

Source: https://habr.com/ru/post/1655023/


All Articles