iOS自定义弹窗(UIView)
来源:互联网 发布:pc mac os x 编辑:程序博客网 时间:2024/05/18 03:54
iOS自定义弹窗(UIView)
效果:
解决:
1. 先放一层 黑色 50%透明度的背景 , 再放弹窗,再在弹窗上放置自定义。
//================================================ //弹窗 //================================================ //中灰背景 UIView *alertBackView = [[UIView alloc] initWithFrame:parentView.frame]; alertBackView.backgroundColor = [UIColor colorWithHex:0x000000 alpha:0.5]; [parentView addSubview:alertBackView]; //弹窗 UIView *alertView = [[UIView alloc] initWithFrame:CGRectMake((parentView.width - kAlertViewWidth) / 2, (parentView.height - kAlertViewHeight) / 2, kAlertViewWidth, kAlertViewHeight)]; alertView.backgroundColor = [UIColor whiteColor]; alertView.layer.cornerRadius = 0.02 * kAlertViewWidth; [alertBackView addSubview:alertView]; //文字 UILabel *labelAlert = [[UILabel alloc] init]; labelAlert.lineBreakMode = NSLineBreakByWordWrapping; labelAlert.numberOfLines = 0; labelAlert.text = @"感谢注册Hi-service平台,点击左侧\n工具箱中的“邀请同事”按钮可以快\n速地邀请同事加入。"; labelAlert.font = [UIFont systemFontOfSize:kContentScaleFactor(24)]; labelAlert.textColor = [UIColor colorWithHex:0x464646 alpha:1]; [labelAlert sizeToFit]; labelAlert.frame = CGRectMake(kContentScaleFactor(50), kContentScaleFactor(60), labelAlert.width, labelAlert.height); [alertView addSubview:labelAlert]; //按钮 UIButton *AlertButton = [[UIButton alloc] initWithFrame:CGRectMake(kContentScaleFactor(62), kContentScaleFactor(60+50)+labelAlert.height, kContentScaleFactor(356), kContentScaleFactor(66))]; [AlertButton setAttributedTitle:[[NSAttributedString alloc] initWithString:@"邀请同事" attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:kContentScaleFactor(28)]}] forState:UIControlStateNormal]; AlertButton.backgroundColor = kAPPThemeColor; AlertButton.layer.cornerRadius = 0.02 * kContentScaleFactor(356); [alertView addSubview:AlertButton];
添加单击手势事件,removeFromSuperView关闭弹窗。
0 0
- iOS自定义弹窗(UIView)
- ios自定义UIView
- ios 自定义uiview
- iOS使用xib自定义uiview
- iOS使用xib自定义uiview
- iOS使用xib自定义UIView
- IOS 自定义 UIView 实现重用
- [iOS 使用xib自定义UIView]
- iOS中标准的自定义控件(UIView的封装)
- ios学习第六天(一)自定义UIView上
- ios学习第六天(二)自定义UIView中
- ios学习第六天(三)自定义UIView下
- iOS自定义控件教程(三)UIView动画入门
- IOS开发 使用XIB自定义一个UIView
- ios--UIView的基本属性和自定义
- iOS自定义alertView,继承自UIView
- IOS开发 使用XIB自定义一个UIView
- IOS开发 使用XIB自定义一个UIView
- iOS开发中一些常用的方法
- spring常问面试题
- pdo_mysql 安装
- 数据可视化指南(干货)
- java代码工具--Date格式化
- iOS自定义弹窗(UIView)
- 第十周项目五 摩托车继承自行车和机动车
- C++常用的字符串处理函数-全
- .h和.cpp文件的区别
- STM32F4学习笔记5——SysTick定时器
- Android系统服务-WindowManager
- 第7周 C语言程序设计(新2版) 练习1-10 输入复制到输出,三种格式替换
- 【mybatis源码分析】原理分析之二:框架整体设计
- 字符编码