wq7tsg
Last Updated: February 25, 2016
·
562
· novalagung
16162fed91387cc1cec055412db0022d

iOS - Sort mutable array of views by each frame

NSComparator comparatorBlock = ^(UIView *obj1, UIView *obj2) {
    if (obj1.frame.origin.y > obj2.frame.origin.y) {
        return (NSComparisonResult)NSOrderedDescending;
    }

    if (obj1.frame.origin.y < obj2.frame.origin.y) {
        return (NSComparisonResult)NSOrderedAscending;
    }
    return (NSComparisonResult)NSOrderedSame;
};

[array sortUsingComparator:comparatorBlock];
Say Thanks
Respond