您的位置:首页 > 其它

navigationbar右侧加两个自定义按钮

2015-09-01 18:45 330 查看
UIView *rightBarView = [[UIViewalloc]initWithFrame:CGRectMake(0,0,
60, 31)];

UIButton *phonebutton = [UIButtonbuttonWithType:UIButtonTypeCustom];
phonebutton.frame=CGRectMake(0,5,
25, 25);
[phonebutton
setImage:[UIImageimageNamed:@"phone.png"]forState:UIControlStateNormal];
[phonebutton
addTarget:self
action:@selector(phoneclick)forControlEvents:UIControlEventTouchDown];
[rightBarView addSubview:phonebutton];

UIButton *mapbutton = [UIButtonbuttonWithType:UIButtonTypeCustom];
[mapbutton setFrame:CGRectMake(30,5,
25, 25)];
[mapbutton
setImage:[UIImageimageNamed:@"c_address.png"]forState:UIControlStateNormal];
[mapbutton
addTarget:self
action:@selector(mapclick)forControlEvents:UIControlEventTouchDown];
[rightBarView addSubview:phonebutton];
[rightBarView addSubview:mapbutton];
rightBarView.backgroundColor=[UIColorclearColor];

UIBarButtonItem *rightBtn = [[UIBarButtonItemalloc]initWithCustomView:rightBarView];
self.navigationItem.rightBarButtonItem = rightBtn;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: