dmitric / DLCImagePickerController

ImagePickerController with live filters, radial blur and more. Brought to you by Backspaces.
www.backspac.es
BSD 3-Clause "New" or "Revised" License
1.56k stars 320 forks source link

Filter Button Customisation #52

Open ChristopherDoherty opened 10 years ago

ChristopherDoherty commented 10 years ago

Hello, I have been using this fantastic library for a little over two month, and by this point I have fully implemented what I will need for my app. However, I was wondering if anyone knew how to add some more customisation to the UIButton's in the Scroll View, so that I can show names of the custom filters, and also how to add a border for the selected filter. I have attempted to do this for a few hours to no avail. Could anyone help with this?

Regards, Christopher

chadkouse commented 10 years ago

Here's how I do a border around the filter button. First turn off all the borders, then set one on the selected one.

-(void) filterClicked:(UIButton *) sender {
    for(UIView *view in self.filterScrollView.subviews){
        if([view isKindOfClass:[UIButton class]]){
            [(UIButton *)view setSelected:NO];
            ((UIButton *)view).layer.borderColor = [[UIColor clearColor] CGColor];
        }
    }

    [sender setSelected:YES];
    sender.layer.borderColor = [[UIColor whiteColor] CGColor];
    [self removeAllTargets];

    selectedFilter = sender.tag;
    [self setFilter:sender.tag];
    [self prepareFilter];
}

to add a label with the name you'd need to edit the loadFilters method and instead of just using the UIButton created there, create your own UIView, add the UIButton and a label, set your label text, then add it

[self.filterScrollView addSubview:yourNewUIView];
ChristopherDoherty commented 10 years ago

Thanks so much, application nearly finished now!