iOSiOS开发交流平台ios

仿微博➕按钮 tarbar➕点击事件(点击旋转45度动画)

2016-08-04  本文已影响810人  轻斟浅醉17

仿照微博写的➕按钮


屏幕快照 2016-08-04 11.06.39.png

点击之后效果:

屏幕快照 2016-08-04 11.06.52.png
- (void)viewDidLoad {
[super viewDidLoad]; 
 self.tabBar.tintColor = [UIColor colorWithRed:254.0f/255.0f green:51.0f/255.0f blue:121.0f/255.0f alpha:1];
UIButton *plusBtn = [UIButton new];
[plusBtn setBackgroundImage:[UIImage imageNamed:@"形状-11"] forState:UIControlStateNormal];
[plusBtn setBackgroundImage:[UIImage imageNamed:@"形状-11"] forState:UIControlStateHighlighted];
[plusBtn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
plusBtn.centerX = self.tabBar.centerX -20;
NSLog(@"%f",plusBtn.centerX);
//调整发布按钮的中线点Y值
plusBtn.centerY = self.tabBar.height * 0.5 - 40 ;
plusBtn.size = CGSizeMake(plusBtn.currentBackgroundImage.size.width, plusBtn.currentBackgroundImage.size.height);
UILabel *label = [[UILabel alloc] init];
label.text = @"发布";
label.font = [UIFont systemFontOfSize:11];
[label sizeToFit];
label.textColor = [UIColor grayColor];
[self.tabBar addSubview:label];
label.centerX = plusBtn.centerX;
label.centerY = CGRectGetMaxY(plusBtn.frame) + 10 ;
[self.tabBar addSubview:plusBtn];   
}
- (void)btnClicked:(UIButton*)btn
{
[self.view addSubview:self.overlayView];
[self.overlayView show];
}

//离开时隐藏View

-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:YES];
    [self.overlayView dismiss];
}

- (GZRotateButtonOverlayView *)overlayView
{
if (_overlayView == nil) {
    _overlayView = [[GZRotateButtonOverlayView alloc] init];
    [_overlayView setTitles:@[@"视频",@"图片"]];
    [_overlayView setTitleImages:@[@"文字",@"图片"]];
    [_overlayView setDelegate:self];
    [_overlayView setFrame:self.view.bounds];
}
return _overlayView;
}

代码传送门:https://github.com/Gang679/demo

屏幕快照 2016-08-04 11.09.18.png

希望的朋友记得star一下!

上一篇 下一篇

猜你喜欢

热点阅读