自定义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方法里面定义了子视图,如果想添加图片或者更改更多控件可以在这个方法里面添加
效果如下所示
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方法里面定义了子视图,如果想添加图片或者更改更多控件可以在这个方法里面添加
相关文章推荐
- UIScrollView控件详解
- String hql = "from SpQuestion as q where q.questionTitle like %?%";
- Arduino - Pro mini 烧录方法 ( FT232RL )
- 解决AndroidStudio添加ProjectLibary后在编译时遇到的各种问题之解决方式索引(finished with non-zero exit value and so on...)
- UIProgressView
- LeetCode 232:Implement Queue using Stacks
- 获取UGUI子节点在Canvas的屏幕坐标
- Bluetooth控件的使用
- 【转】Pro Android学习笔记(十三):用户界面和控制(1):UI开发
- 更改 UIImagePickerController 导航条文字的颜色
- 关于msdn中NtQuerySystemInformation函数说明
- UIScrollView 实践经验
- 300. Longest Increasing Subsequence
- UI-9-UITableView
- Android UI-仿微信底部导航栏布局
- android 更新UI的两种方法
- iOS开发UI篇—ios应用数据存储方式(归档)
- UITableView没数据时提示没有更多数据
- Acronis True Image进行…
- loadrunner web_custom_request 脚本处理