在标题栏添加多个按钮

UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 150, 45)];

    [tools setTintColor:[self.navigationController.navigationBar tintColor]];

    [tools setAlpha:[self.navigationController.navigationBar alpha]];

    NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:2];



    UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd

                            target:self actionselector(clickSettings:)];



    UIBarButtonItem *anotherButton1 = [[UIBarButtonItem alloc] initWithTitle"Edit" style:UITabBarSystemItemContacts

                                                            target:self actionselector(clickEdit:)];

    [buttons addObject:anotherButton];

    [anotherButton release];

    [buttons addObject:anotherButton1];

    [anotherButton1 release];

    [tools setItems:buttons animated:NO];

    [buttons release];

    UIBarButtonItem *myBtn = [[UIBarButtonItem alloc] initWithCustomView:tools];

    self.navigationItem.rightBarButtonItem = myBtn;



    [myBtn release];

    [tools release];

posted @ 2013-01-19 17:17  rui90102  阅读(294)  评论(0编辑  收藏  举报