[Self.navigationController.navigationBar setshadowimage:[static colortoimage:[static Colorwithhexstring:[uicolor Red]];
A few static methods in static
+ (UIImage *) Colortoimage: (Uicolor *) color{ cgrect rect=cgrectmake (0.0f0.0f1.0f 1.0f); Uigraphicsbeginimagecontext (rect.size); = Uigraphicsgetcurrentcontext (); Cgcontextsetfillcolorwithcolor (context, [color Cgcolor]); Cgcontextfillrect (context, rect); *theimage = uigraphicsgetimagefromcurrentimagecontext (); Uigraphicsendimagecontext (); return theimage;}
+ (Uicolor *) colorwithhexstring: (NSString *) color{NSString*cstring =[[Color Stringbytrimmingcharactersinset:[nscharacterset Whitespaceandnewlinecharacterset]] uppercaseString]; if([cString Length] <6) { return[Uicolor Clearcolor]; } if([cString Hasprefix:@"0X"]) cString= [CString Substringfromindex:2]; if([cString Hasprefix:@"#"]) cString= [CString Substringfromindex:1]; if([cString length]! =6) return[Uicolor Clearcolor]; //SplitNsrange Range; Range.location=0; Range.length=2; //RNSString*rstring =[cString Substringwithrange:range]; //Grange.location=2; NSString*gstring =[cString Substringwithrange:range]; //Brange.location=4; NSString*bstring =[cString Substringwithrange:range]; //ScanunsignedintR, G, B; [[Nsscanner scannerwithstring:rstring] Scanhexint:&R]; [[Nsscanner scannerwithstring:gstring] Scanhexint:&G]; [[Nsscanner scannerwithstring:bstring] Scanhexint:&b]; return[Uicolor colorwithred: ((float) R/255.0f) Green: ((float) G/255.0f) Blue: ((float) b/255.0f) Alpha:1.0f];}
Modify the Navigationbar color of a root line