The only options for styling I saw in the API are:
Is it possible to somehow paint the buttons in another color? Our designer really didn't liked the default blue buttons
No, it is not possible to change button colors in UIPreviewAction. Even if you add colored images it will switch to default blue color.
Try this:
myPreviewAction.tintColor = myColor
With this UIPreviewAction extension:
extension UIPreviewAction {
var tintColor: UIColor? {
get {
return value(forKey: "_color") as? UIColor
}
set {
setValue(newValue, forKey: "_color")
}
}
}
You can add these snippets on below for the viewcontroller which implements UIPreviewAction
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
UIView *containerView = [self.view superviewOfClass:NSClassFromString(@"_UIVisualEffectContentView")];
containerView.tintColor = YOUR_CUSTOM_COLOR;
}
In a UIView category
- (UIView *)superViewOfClass:(Class)class {
UIView *parent = self;
while ((parent = parent.superview)) {
if ([parent isKindOfClass:class]) {
return parent;
}
}
return nil;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With