Flow layout - Free form view placement


#1

I am experimenting with the Flow layout, and I was wondering if theres anyway to enable freeform placement of items, while still retaining the “flow” feature for nearby/intersecting items?

For instance, Id like to add several items on the top of the screen, but be able to drag a single item of those to a specific spot on the screen, while still allowing the others to respond if I place something that would not fit.

For illustration, imagine the X are icons, and O are just whitespace

Id like to go from this:

XXX
OOO
OOO

to this:

XXO
OOO
OXO


#2

Greetings Program!

You can achieve this by adding clear views to the flow layout (I modified the FlowLayoutGettingStarted sample app):

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [ShinobiEssentials setLicenseKey:@""]; // Trial Users - Add license key here

    self.myFlowLayout = [[SEssentialsFlowLayout alloc] initWithFrame:self.view.bounds
                                                withDeleteIdiom:SEssentialsFlowDeleteIdiomTrashCan];
    [self importViews];
    self.myFlowLayout.verticalSubviewAlignment = SEssentialsAlignBottom;
    [self.view addSubview:self.myFlowLayout];
}

- (void)importViews {
    NSArray *colors = @[[UIColor redColor], [UIColor greenColor], [UIColor blueColor]];
    for (int i = 0; i < 10; i++){
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 75, 75)];
        view.backgroundColor = i < 3 ? colors[i] : [UIColor clearColor];
        
        [self. myFlowLayout addManagedSubview:view];
    }
}

Wg