//先自己寫一個titleViewUIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 20)];//allocate titleViewtitleView.backgroundColor=[UIColor blackColor];//Create UILableUILabel*titleText = [[UILabel alloc] initWithFrame: CGRectMake(100, 0, 50, 20)];//allocate titleTexttitleText.backgroundColor = [UIColor clearColor];[titleText setText:@"Title"];[titleView addSubview:titleText];[titleText release];//release titleText//Create Round UIButtonUIButton *btnNormal = [UIButton buttonWithType:UIButtonTypeRoundedRect];[btnNormal setFrame:CGRectMake(0, 0, 40, 20)];[btnNormal addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];[btnNormal setTitle:@"Normal" forState:UIControlStateNormal];[btnNormal setFont:[UIFont systemFontOfSize:8]];[titleView addSubview:btnNormal];//Set to titleView self.navigationItem.titleView = titleView;[titleView release];//release titleView//Custom backgroundImage UIButtonUIButton *btnCustom = [UIButton buttonWithType:UIButtonTypeRoundedRect];[btnCustom setFrame:CGRectMake(0, 0, 32, 32)];[btnCustom addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];[btnCustom setTitle:@"CB" forState:UIControlStateNormal];[btnCustom setBackgroundImage:[UIImage imageNamed:@"whiteButton.png"] forState:UIControlStateNormal];[btnCustom setBackgroundImage:[UIImage imageNamed:@"blueButton.png"] forState:UIControlStateHighlighted];//Create UIBarButtonItem with the customed buttonUIBarButtonItem *rightBarButton = [[UIBarButtonItem alloc] initWithCustomView:btnCustom];//allocate rightBarButton//Set to rightBarButtonItemself.navigationItem.rightBarButtonItem = rightBarButton;[rightBarButton release];//release rightBarButton