mixtly87 mixtly87 - 1 month ago 11
iOS Question

How to tint peek&pop custom actions?

When pick&pop view is presented, custom actions (

UIPreviewAction
objects) are shown in default iOS blue color.
Is there any way they can be tinted in different color?

Answer

Here's how I solved it in the end:

in viewWillAppear method of a preview controller (viewController which implements previewActionItems method add:

- (void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    UIView* container = [self.view superviewOfClass:NSClassFromString(@"_UIVisualEffectContentView")];
    container.tintColor = [CDThemeManager sharedTheme].colorPrimaryActive;
}

The superviewOfClass method is implemented in UIView+MyUtils category:

- (UIView*) superviewOfClass:(Class)c
{
    UIView* parent = self;
    while ((parent = parent.superview))
    {
        if ([parent isKindOfClass:c])
        {
            return parent;
        }
    }
    return nil;
}