最近做弹出相册选择等的弹出框,自己做了一个。互相学习一下。。。
直接上代码
@property (strong,nonatomic) UIWindow *windowButtonMineView;//悬浮
#pragma mark 修改图像响应方法
- (void)btnUserImageClick:(UIButton *)sender {
_windowButtonMineView = [[UIWindow alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, 140)];
_windowButtonMineView.windowLevel = UIWindowLevelAlert;
//_windowButton.backgroundColor = [UIColor colorWithRed:233 green:233 blue:233 alpha:1.0];
_windowButtonMineView.backgroundColor = ColorViewBackground;
float btnWidth = _windowButtonMineView.frame.size.width,btnHeigth = 40;
UIButton *btnEditImage1 = [[UIButton alloc] initWithFrame:CGRectMake(0, 1, btnWidth, btnHeigth)];
[btnEditImage1 setTitle:@"拍照" forState:UIControlStateNormal];
[btnEditImage1 setTitleColor:ColorTextFondColor forState:UIControlStateNormal];
btnEditImage1.backgroundColor = [UIColor whiteColor];
btnEditImage1.tag = 2;
[btnEditImage1 addTarget:self action:@selector(btnImageBackClickInMineView:) forControlEvents:UIControlEventTouchUpInside];
[_windowButtonMineView addSubview:btnEditImage1];
UIButton *btnEditImage2 = [[UIButton alloc] initWithFrame:CGRectMake(0, 42, btnWidth, btnHeigth)];
[btnEditImage2 setTitle:@"从手机相册选择" forState:UIControlStateNormal];
[btnEditImage2 setTitleColor:ColorTextFondColor forState:UIControlStateNormal];
btnEditImage2.backgroundColor = [UIColor whiteColor];
btnEditImage2.tag = 1;
[btnEditImage2 addTarget:self action:@selector(btnImageBackClickInMineView:) forControlEvents:UIControlEventTouchUpInside];
[_windowButtonMineView addSubview:btnEditImage2];
UIButton *btnEditImage4 = [[UIButton alloc] initWithFrame:CGRectMake(0, 100, btnWidth, btnHeigth)];
btnEditImage4.backgroundColor = [UIColor whiteColor];
[btnEditImage4 setTitle:@"取消" forState:UIControlStateNormal];
[btnEditImage4 setTitleColor:ColorTextFondColor forState:UIControlStateNormal];
[btnEditImage4 addTarget:self action:@selector(BtnCloseImageWindowsInMineView) forControlEvents:UIControlEventTouchUpInside];
[_windowButtonMineView addSubview:btnEditImage4];
//显示window
[_windowButtonMineView makeKeyAndVisible];
//设置动画的名字
[UIView beginAnimations:@"Animation" context:nil];
//设置动画的间隔时间
[UIView setAnimationDuration:0.50];
//??使用当前正在运行的状态开始下一段动画
[UIView setAnimationBeginsFromCurrentState: YES];
//设置视图移动的位移
_windowButtonMineView.frame = CGRectMake(0, self.view.frame.size.height-140, self.view.frame.size.width, 140);
//设置动画结束
[UIView commitAnimations];
}
#pragma mark 关闭windows视图
-(void)BtnCloseImageWindowsInMineView{
//关闭UIwindow
[self performSelector:@selector(scale_1) withObject:nil afterDelay:0.0f];
[self performSelector:@selector(scale_2) withObject:nil afterDelay:0.5f];
}
//以下是启动页动画效果
-(void)scale_1
{
//设置动画的名字
[UIView beginAnimations:@"Animation" context:nil];
//设置动画的间隔时间
[UIView setAnimationDuration:0.50];
//??使用当前正在运行的状态开始下一段动画
[UIView setAnimationBeginsFromCurrentState: YES];
//设置视图移动的位移
_windowButtonMineView.frame = CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, 140);
//设置动画结束
[UIView commitAnimations];
}
-(void)scale_2
{
//关闭UIwindow
_windowButtonMineView.hidden = YES;
[_windowButtonMineView resignKeyWindow];
_windowButtonMineView = nil;
}