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

来源:互联网 发布:程序员开发手册 编辑:程序博客网 时间:2024/05/17 23:30

仿照微博写的➕按钮

 

点击之后效果:



- (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];}
//离开时隐藏
-(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

记得star一下!


0 0
原创粉丝点击