iphone - Disable Border Around System Image Located UINavigationBarItem -
i want disable border around iphone sdk's add button, it's "+" button (no black bg):
this seems simple task when it's located in toolbar, not when it's located in uinavigationbar. anyways, if knows how, or if it's possible, please share! here's current code in rootviewcontroller.m:
self.title = @"code master"; addbutton = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemadd target:self action:@selector(addbuttonclicked:)]; self.navigationitem.rightbarbuttonitem = addbutton;
edit
@dee code works great, displays want! there problem i'll explain:
edit button: left side of uinavigationbar
done button: left side of uinavigationbar (hidden); when edit button clicked, replaces edit button "done" button
plus button: right side of uinavigationbar; hides when in "edit mode", shows when in "normal mode (when done button not visible)"
so problem whenever click edit, done, plus button doesn't return hiding. i'm using exact code , worked previous code. i'm pretty sure it's because in code, theres nothing labelling "addbutton". here's code later on in main file:
-(void)setediting:(bool)editing animated:(bool)animated { [super setediting:editing animated:yes]; if (editing) { self.navigationitem.rightbarbuttonitem = nil; } else { uibutton *button = [uibutton buttonwithtype:uibuttontypecustom]; [button setimage:[uiimage imagenamed:@"plus.png"] forstate:uicontrolstatenormal]; [button addtarget:self action:@selector(addbuttonclicked:) forcontrolevents:uicontroleventtouchupinside]; [button setframe:cgrectmake(0, 0, 50, 29)]; uibarbuttonitem *barbtn = [[uibarbuttonitem alloc] initwithcustomview:button]; self.navigationitem.rightbarbuttonitem = barbtn; [barbtn release]; } [self.tableview reloaddata]; }
create "+" image , set button & give button uibarbuttonitem this:
uibutton *button = [uibutton buttonwithtype:uibuttontypecustom]; [button setimage:[uiimage imagenamed:@"plus.png"] forstate:uicontrolstatenormal]; [button addtarget:self action:@selector(addbuttonclicked:) forcontrolevents:uicontroleventtouchupinside]; [button setframe:cgrectmake(0, 0, 50, 29)]; uibarbuttonitem *barbtn = [[uibarbuttonitem alloc] initwithcustomview:button]; [self.navigationitem setrightbarbuttonitem:barbtn]; [barbtn release];
Comments
Post a Comment