2016-09-02 37 views

回答

3

否视图 - 控制,它是无法在UIPreviewAction中更改按钮颜色。即使您添加彩色图像,它也会切换为默认的蓝色。

1

您可以在下方加入这些片段为它实现UIPreviewAction

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

在一个UIView类

- (UIView *)superViewOfClass:(Class)class { 
    UIView *parent = self; 
    while ((parent = parent.superview)) { 
     if ([parent isKindOfClass:class]) { 
      return parent; 
     } 
    } 
    return nil; 
} 
+1

呀,我想我宁愿不使用这些解决方案。 iOS更新很容易中断。但是,谢谢 –

1

试试这个:

myPreviewAction.tintColor = myColor 

有了这个UIPreviewAction扩展:

extension UIPreviewAction { 

    var tintColor: UIColor? { 
     get { 
      return value(forKey: "_color") as? UIColor 
     } 
     set { 
      setValue(newValue, forKey: "_color") 
     } 
    } 

} 
相关问题