ios - 如何为 peek&pop 自定义操作着色?

标签 ios 3dtouch tintcolor

当显示选择&弹出 View 时,自定义操作(UIPreviewAction 对象)以默认的 iOS 蓝色显示。
有什么办法可以把它们染成不同的颜色吗?

最佳答案

对于 iOS 11,似乎可行的是添加 didFinishLaunchingWithOptions :

UIApplication.sharedApplication.delegate.window.tintColor = MY_COLOR

我不确定相同的方法是否适用于 iOS11 之前的版本,但以下是对我来说适用于 iOS11 之前的方法:

viewWillAppear预览 Controller 的方法(实现 previewActionItems 方法的 viewController 添加:
- (void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    UIView* container = [self.view superviewOfClass:NSClassFromString(@"_UIVisualEffectContentView")];
    container.tintColor = YOUR_COLOR;
}
superviewOfClass方法在 UIView+MyUtils 中实现类别:
- (UIView*) superviewOfClass:(Class)c
{
    UIView* parent = self;
    while ((parent = parent.superview))
    {
        if ([parent isKindOfClass:c])
        {
            return parent;
        }
    }
    return nil;
}

关于ios - 如何为 peek&pop 自定义操作着色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40172268/

相关文章:

ios - 应用内购买商店用户界面要求

ios - 如何在 SpriteKit 中获得类似于 peek 或 pop 的 3d touch 应用程序图标触觉反馈

iphone - 如何为特定的 UIBarButtonItem 着色?

iphone - UIsegmentedControl setTintColor 奇怪的行为

ios - 使用 Swift 从 xib/nib 实例化 UIView

ios - 应用程序在设备上崩溃但在模拟器上不崩溃

ios - 使用 3D touch peek and pop,您如何检测用户在 peek 期间的平移(如 Facebook)?

ios - 从 Peek 到邮件的 UIPreviewAction

ios8 - UIAlertController 错误更改其他 UIImageViews 的 tintcolor

ios - UICollectionView performBatchUpdates 导致 collectionview 在旋转设备时错位