自定义的UIBarButtonItem
2012-02-16 17:13 java环境变量 阅读(195) 评论(0) 编辑 收藏 举报UIImage* image= [UIImage imageNamed:@"绑定弹出-返回.png"];
CGRect frame_1= CGRectMake(0, 0, image.size.width, image.size.height-4);
UIButton* backButton= [[UIButton alloc] initWithFrame:frame_1];
[backButton setBackgroundImage:image forState:UIControlStateNormal];
[backButton setTitle:@"返回" forState:UIControlStateNormal];
[backButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
backButton.titleLabel.font=[UIFont systemFontOfSize:16];
[backButton addTarget:self action:@selector(doBack:) forControlEvents:UIControlEventTouchUpInside]; //定制自己的风格的 UIBarButtonItem
UIBarButtonItem* someBarButtonItem= [[UIBarButtonItem alloc] initWithCustomView:backButton];
[self.navigationItem setLeftBarButtonItem:someBarButtonItem];
[someBarButtonItem release];
[backButton release];