自定义leftBarButtonItem的button

     self.navigationItem.title=@"经销商查询";

    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];

    button.frame=CGRectMake(0, 0, 50, 30);

    [button setBackgroundImage:[UIImage imageNamed:@"[email protected]"] forState:UIControlStateNormal];

    [button setTitle:@"返回" forState:UIControlStateNormal];

    button.titleLabel.font=[UIFont systemFontOfSize:14];

    button.titleLabel.textAlignment=UITextAlignmentCenter;

    button.backgroundColor=[UIColor clearColor];

    [button addTarget:self action:@selector(pop) forControlEvents:UIControlEventTouchUpInside];

    UIBarButtonItem * leftButton = [[UIBarButtonItem alloc]initWithCustomView:button];

    self.navigationItem.leftBarButtonItem=leftButton;

    [leftButton release];

本文出自 “yangjun” 博客,谢绝转载!

你可能感兴趣的:(button,的)