您的位置:首页 > 产品设计 > UI/UE

自定义UIAlertView

2015-12-15 13:53 393 查看
有时候系统的UIAlertView不一定能够满足我们的编程需求,需要我们自定义alertView,我写了一个简单的定义了界面有主标题,副标题的UIAlertView

效果如下所示

demo地址:https://github.com/tuwanli/DefinedSelf



只需要在你的控制器里面写入提示文字:温馨提示、主标题:确定要创建吗、副标题:红色字体的显示

TWLAlertView *alertView = [[TWLAlertView
alloc]initWithFrame:CGRectMake(0,
0, [UIScreen
mainScreen].bounds.size.width,
[UIScreen
mainScreen].bounds.size.height)];

[alertView AlertView:@"确定要创建吗?"
minorTitle:@"创建之前要要好好阅读提示,不要做出错误的决定,下面的按钮提示创建或者取消由你自己决定的,github中还有更换头像,单选照片,多选照片的demo"
tipString:@"温馨提示"];
alertView.delegate =
self;
[self.view
addSubview: alertView];
在TWLAlertView里面定义alertView弹出框的所有子视图,以及弹出动画

-(void)exChangeOut:(UIView *)changeOutView dur:(CFTimeInterval)dur{

CAKeyframeAnimation * animation;
animation = [CAKeyframeAnimation
animationWithKeyPath:@"transform"];
animation.duration = dur;

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];
}

在- (void)creatViewInAlert方法里面定义了子视图,如果想添加图片或者更改更多控件可以在这个方法里面添加
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: