ios 自定义弹出对话框效果
简单的实现自定义对话框
-(void)openWindow{
alterView=[[UIView alloc]initWithFrame:CGRectMake(120, 250,320,150)];
alterView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"tankuang.png"]];
[self.view addSubview:alterView];
textIP=[[UITextField alloc]initWithFrame:CGRectMake(15, 50, 300,50)];
textIP.borderStyle=0;
textIP.backgroundColor=[UIColor clearColor];
textIP.textColor=[UIColor blackColor];
[alterView addSubview:textIP];
textIP.keyboardType=UIKeyboardTypeAlphabet;
[textIP becomeFirstResponder];
UIButton *btnOK=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[btnOK setBackgroundImage:[UIImage imageNamed:@"quxiao.png"] forState:UIControlStateNormal];
btnOK.frame=CGRectMake(50, 100, 60, 29);
btnOK.tag=0;
[btnOK addTarget:self action:@selector(setIP:) forControlEvents:UIControlEventTouchUpInside];
[alterView addSubview:btnOK];
UIButton *btnCacel=[UIButton buttonWithType:UIButtonTypeRoundedRect];
btnCacel.tag=1;
[btnCacel setBackgroundImage:[UIImage imageNamed:@"queren.png"] forState:UIControlStateNormal];
[btnCacel addTarget:self action:@selector(setIP:) forControlEvents:UIControlEventTouchUpInside];
btnCacel.frame=CGRectMake(200, 100, 60, 29);
[alterView addSubview:btnCacel];
[self exChangeOut:alterView dur:0.5];
}
加上苹果的弹出效果
-(void)exChangeOut:(UIView *)changeOutView dur:(CFTimeInterval)dur{ CAKeyframeAnimation * animation; animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"]; animation.duration = dur; //animation.delegate = self; animation.removedOnCompletion = NO; animation.fillMode = kCAFillModeForwards; NSMutableArray *values = [NSMutableArray array]; [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)]]; [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)]]; [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 0.9)]]; [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]]; animation.values = values; animation.timingFunction = [CAMediaTimingFunction functionWithName: @"easeInEaseOut"]; [changeOutView.layer addAnimation:animation forKey:nil]; }