ios - UINavigationBar appearance proxy when contained in UIPopoverController -
i i'm doing supposed work in ios7 , 8, reason doesn't. want customize navigation bar properties via appearance proxy , want applied navigation bars ones within uipopover
.
so, first step following:
uinavigationbar *appearance = [uinavigationbar appearance]; appearance.bartintcolor = [uicolor redcolor]; appearance.titletextattributes = @{ nsforegroundcolorattributename: [uicolor yellowcolor] };
this supposed create navigation bars reddish yellowish title. works in ios8. work in ios7. reason when view controller beingness presented within uipopovercontroller - gets default appearance.
this how nowadays popover (nothing fancy - standard sample code):
uiviewcontroller *vc = [self.storyboard instantiateviewcontrollerwithidentifier:@"vc2"]; vc.title = @"view controller 2"; uinavigationcontroller *nav = [[uinavigationcontroller alloc] initwithrootviewcontroller:vc]; self.popover = [[uipopovercontroller alloc] initwithcontentviewcontroller:nav]; [self.popover presentpopoverfromrect:cgrectmake(100, 100, 100, 100) inview:self.view permittedarrowdirections:0 animated:yes];
ok, decided seek appearancewhencontainedin
, explicitly set appearance there. added next code initial appearance customization:
appearance = [uinavigationbar appearancewhencontainedin:[uipopovercontroller class], nil]; appearance.bartintcolor = [uicolor greencolor]; appearance.titletextattributes = @{ nsforegroundcolorattributename: [uicolor bluecolor] };
now. reason lastly code doesn't impact anything. in ios8 navigation bars within uipopovercontrollers still reddish + yellow, not greenish + blue, , ios7 still uses default appearance.
what doing wrong here?
here link test project: https://dl.dropboxusercontent.com/u/6402890/testappearance.zip
for ios 8
ns_class_available_ios(8_0) @interface uipopoverpresentationcontroller : uipresentationcontroller
using next worked me. navigation controller contained in uipopoverpresentationcontroller.
appearance = [uinavigationbar appearancewhencontainedin:[uipopoverpresentationcontroller class], nil];
for ios 7
appearance = [uinavigationbar appearancewhencontainedin:[uipopovercontroller class], nil]; uinavigationcontroller *nav = [[uinavigationcontroller alloc] initwithrootviewcontroller:vc]; nav.navigationbar.barstyle = uibarstyleblack;
if navigation controller loaded storyboard, barstyle needed set uibarstyleblack in storyboard.
ios objective-c cocoa-touch uiappearance
No comments:
Post a Comment