凸出按钮的TabBar
2017-07-05 本文已影响3人
吓死宝宝了啊
- (void)addCenterBtn{
UIImage * image = [UIImage imageNamed:@"money"];
UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setImage:image forState:UIControlStateNormal];
btn.frame = CGRectMake(0, 0, image.size.width, image.size.height);
[btn addTarget:self action:@selector(centerClicked) forControlEvents:UIControlEventTouchUpInside];
//设置凸出按钮的位置
CGPoint center = self.tabBar.center;
center.y -= 15;
btn.center = center;
//去掉点击按钮时的阴影
btn.adjustsImageWhenHighlighted = NO;
[self.view addSubview:btn];
}
- (void)centerClicked{
self.selectedIndex = 1;
}