1.
Objectice-c Code:
1Nsshadow *shadow = [NsshadowNew];2 3[Shadow Setshadowcolor:[uicolor colorwithred:1.0Green1.0Blue1.0Alpha1.0]];4 5[Shadow Setshadowoffset:cgsizemake (0,1)];6 7Nsdictionary *attributes = @{8 9Nsforegroundcolorattributename: [Uicolor colorwithred:220.0/255.0Green104.0/255.0Blue1.0/255.0Alpha1.0],Ten One Nsshadowattributename:shadow, A -Nsfontattributename: [Uifont fontwithname:@"Americantypewriter"Size16.0] - the }; - - [Self.navigationItem.rightBarButtonItem settitletextattributes:attributes forstate:uicontrolstatenormal]; - + //Or you can use. - +[[Uibaritem appearance] settitletextattributes:attributes Forstate:uicontrolstatenormal];
Swift Code:
//Bar title text colorLet shadow=Nsshadow () Shadow.shadowcolor= Uicolor (red:1.0, Green:1.0, Blue:1.0, Alpha:1.0) Shadow.shadowoffset= Cgsizemake (0,1) Let Color:uicolor= Uicolor (red:220.0/255.0, Green:104.0/255.0, Blue:1.0/255.0, Alpha:1.0) Let Titlefont:uifont= Uifont (Name:"Americantypewriter", Size:16.0)!Let attributes=[Nsforegroundcolorattributename:color, Nsshadowattributename:shado W, Nsfontattributename:titlefont]self.navigationitem.rightbarbuttonitem?. Settitletextattributes (attributes, ForState:UIControlState.Normal)//Or You can useuibaritem.appearance (). Settitletextattributes (attributes, ForState:UIControlState.Normal)
Swift and OC Code conversion examples