2016-09-02 4 views
9

केवल विकल्प हैं:क्या UIPreviewAction रंग बदलना संभव है? मैं एपीआई में देखा स्टाइल के लिए

  • UIPreviewActionStyleDefault
  • UIPreviewActionStyleSelected,
  • UIPreviewActionStyleDestructive

यह किसी भी तरह किसी अन्य रंग में बटन पेंट करने के लिए संभव है? हमारे डिजाइनर वास्तव में डिफ़ॉल्ट नीले बटन

+0

मुझे लगता है कि यह उत्तर दिया जाता है [यहां] (http://stackoverflow.com/a/26770557/790842) – iphonic

उत्तर

3

नहीं में के लिए नीचे पर इन स्निपेट जोड़ सकते हैं, यह है UIPreviewAction में बटन रंग बदलने के लिए संभव नहीं है। यहां तक ​​कि यदि आप रंगीन छवियों को जोड़ते हैं तो यह डिफ़ॉल्ट नीले रंग में बदल जाएगा।

1

पसंद आया नहीं था आप ViewController जो 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

हाँ , मुझे लगता है कि मैं इस तरह के समाधान का उपयोग नहीं करना पसंद करता हूं। आईओएस अपडेट के साथ तोड़ना बहुत आसान है। लेकिन आपका शुक्रिया –

1

इस प्रयास करें:

myPreviewAction.tintColor = myColor 
इस UIPreviewAction एक्सटेंशन के साथ

:

extension UIPreviewAction { 

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

} 
संबंधित मुद्दे