Mac_Psi Posted August 27, 2008 Share Posted August 27, 2008 Hi, I want to change the color of my UIBarButtonItem to RED but I think there is no direct method or property to that. So, I am doing this: UIButton *pCustomButton = [uIButton buttonWithType:UIButtonTypeRoundRect]; [pCustomButton addTarget:self action:@selector(Logout:) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *pLogOut = [[uIBarButtonItem alloc] initWithCustomView:pCustomButton]; pLogOut.title = @"LogOut"; self.navigationItem.leftBarButtonItem = pLogOut; But my button is not appearing on the navigation bar. Any Ideas? what should I do now? Thanks in advance MacDev Link to comment Share on other sites More sharing options...
FishYaker Posted September 3, 2008 Share Posted September 3, 2008 Hi, I want to change the color of my UIBarButtonItem to RED but I think there is no direct method or property to that. So, I am doing this: UIButton *pCustomButton = [uIButton buttonWithType:UIButtonTypeRoundRect]; [pCustomButton addTarget:self action:@selector(Logout:) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *pLogOut = [[uIBarButtonItem alloc] initWithCustomView:pCustomButton]; pLogOut.title = @"LogOut"; self.navigationItem.leftBarButtonItem = pLogOut; But my button is not appearing on the navigation bar. Any Ideas? what should I do now? Thanks in advance MacDev You have to create a frame and then attach the frame to the button before adding it to the UIBarButtonItem. Like this: pCustomButton.frame=CGRectMake(0.0, 100.0, 50.0, 30.0) Link to comment Share on other sites More sharing options...
Recommended Posts