2013-10-24 6 views
7

का उपयोग कर iOS7 में, डिफ़ॉल्ट रूप से UIBarButtonItem शैली UIBarButtonItemStylePlain के लिए एक Helvetica नियमित रूप से वजन फ़ॉन्ट और UIBarButtonItemStyleDone के लिए एक साहसिक वजन का उपयोग करता है।iOS7 में, UIBarButtonItems का सम्मान नहीं करते हैं बोल्ड "हो गया" स्टाइल जब UIAppearance प्रॉक्सी

मेरा ऐप कस्टम फोंट का उपयोग करता है, और मैं इस लक्ष्य को हासिल करने के लिए एक UIAppearance प्रॉक्सी उपयोग कर रहा हूँ:

appearance = @{NSFontAttributeName: [UIFont fontWithName:@"ProximaNova-Regular" size:18.0]}; 
[[UIBarButtonItem appearance] setTitleTextAttributes:appearance 
              forState:UIControlStateNormal]; 

मुसीबत, उपस्थिति प्रॉक्सी बनाता है सादा और हो गया स्टाइल बटन मैं ऊपर निर्दिष्ट नियमित रूप से वजन फ़ॉन्ट ।

कोई विचार है कि मैं शैली के आधार पर विभिन्न कस्टम फ़ॉन्ट वजन का उपयोग करने के लिए UIBarButtonItem कैसे प्राप्त कर सकता हूं?

+0

अरे मार्क मेरी टाइपो का पता लगाने के लिए धन्यवाद, मैं जानता हूँ कि यह एक लंबे समय से अपेक्षित है उत्तर दिया लेकिन क्या आपने UIBarButtonItem को उप-वर्गीकरण करने और कस्टम दृश्य जोड़ने का प्रयास किया? इस उत्तर को यहां देखें: http://stackoverflow.com/questions/18844681/how-to-make-custom-uibarbuttonitem-with-image-and-label। उम्मीद है कि यह मदद करता है :) –

उत्तर

3

मैं जानता हूँ कि यह देर से जवाब है, लेकिन यह किसी के लिए उपयोगी हो सकता है:

UIBarButtonItem *customBarButton = 
     [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"CustomTitle", @"This button appears in my smexy ViewController's naviagtion bar") 
             style:UIBarButtonItemStylePlain 
             target:self 
             action:@selector(customButtonDidClick:)]; 

    NSDictionary *attributes = @{NSFontAttributeName: [UIFont fontWithName:@"TimesNewRomanPS-BoldMT" size:14.0f], 
           NSForegroundColorAttributeName: [UIColor redColor]}; // here you can add some other keys (especially in iOS 7) to personalize your button title more 

    [customBarButton setTitleTextAttributes:attributes forState:UIControlStateNormal]; 

    [self.navigationItem setRightBarButtonItem:customBarButton]; 

संपादित: :-)

+0

धन्यवाद @Neru! यह काम करता है। एफवाईआई: फ़ॉन्ट स्ट्रिंग के सामने @ गायब है। –

+0

मदद करने में खुशी हुई :-) – Neru

+1

मुझे समझ में नहीं आ रहा है कि यह कोड समस्या को हल करने के लिए कैसे काम करेगा ... – Fry

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