AlertController
iOS8以后系统的提示框改为了UIAlertController,下面利用KVC来更改标题、提示的字体以及颜色
NSMutableAttributedString *attTitle = [[NSMutableAttributedString alloc]initWithString:@"标题1" attributes:@{NSForegroundColorAttributeName:[UIColor blueColor],NSFontAttributeName:[UIFont systemFontOfSize:17]}];
NSMutableAttributedString *attMessage = [[NSMutableAttributedString alloc]initWithString:@"message" attributes:@{NSForegroundColorAttributeName:[UIColor purpleColor],NSFontAttributeName:[UIFont systemFontOfSize:14]}];
UIAlertController *action = [UIAlertController alertControllerWithTitle:@"标题1" message:@"message" preferredStyle:UIAlertControllerStyleActionSheet];
[action setValue:attTitle forKey:@"attributedTitle"];
[action setValue:attMessage forKey:@"attributedMessage"];
UIAlertAction *alert1 = [UIAlertAction actionWithTitle:@"拍摄" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[self loadCameraMovie];
}];
[alert1 setValue:[UIColor greenColor] forKey:@"titleTextColor"];
[action addAction:alert1];
UIAlertAction *alert2 = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[self loadCamera];
}];
[alert2 setValue:[UIColor cyanColor] forKey:@"titleTextColor"];
[action addAction:alert2];
UIAlertAction *alert3 = [UIAlertAction actionWithTitle:@"从相册选择视频" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[self loadPhotoLibraryMovie];
}];
[alert3 setValue:[UIColor orangeColor] forKey:@"titleTextColor"];
[action addAction:alert3];
UIAlertAction *alert4 = [UIAlertAction actionWithTitle:@"从相册选择照片" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[self loadPhotoLibraryPhoto];
}];
[alert4 setValue:[UIColor brownColor] forKey:@"titleTextColor"];
[action addAction:alert4];
UIAlertAction *alert5 = [UIAlertAction actionWithTitle:@"从相册选择多张照片" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[self loadQBImagePickerController];
}];
[alert5 setValue:[UIColor blackColor] forKey:@"titleTextColor"];
[action addAction:alert5];
UIAlertAction *can = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
[can setValue:[UIColor redColor] forKey:@"titleTextColor"];
[action addAction:can];
[self presentViewController:action animated:YES completion:nil];
使用runtime
来获取系统属性key
unsigned int count = 0;
Ivar *ivars = class_copyIvarList(NSClassFromString(@"CYObject"), &count);
//ivars不是数组而是内存地址
NSLog(@"count:%d",count);
for (int i = 0; i < count; i++) {
//获取成员变量
Ivar ivar = ivars[i];
const char *name = ivar_getName(ivar);
NSString *sname = [NSString stringWithUTF8String:name];
NSLog(@"name:%@",sname);
}
free(ivars);
FEATURED TAGS
iOS
OC
C
Xcode
MIMEType
屏幕旋转
Mac
工具
SQLite3
重命名
证书+内购
像素
pch
支付协议税务
APP转让
审核
银行卡格式化
git
描述文件
命令行
沙盒日志
i386
x86_64
控制台log
xcode10&iOS12
正则
textfield
输入限制
Pod
真机支持
封面尺寸
SDWebImage
Ruby
RVM
渐变色
jekyll
水印
富文本
标签
M3U8
动、静态库
异步上传
Url编码解码
AlertController
保活
pod报错
特定UI横竖屏
Launch版本号
ijkplayer
适配
手势
截图
网络和信号
礼物缓存
手绘礼物
UIPickerView
文件权限
键盘和菜单
耗时卡顿
国际化
Paypal
AWSS3
npm、Node
控制台
warning
扩展
防盗链
动画
分析
CallKit
侧滑
重置根控制器
播放器
裁剪
日志
bugly
uniapp
Swift
文字翻转
跨域
WebClip
网络请求
地图导航
ZSH
SPM
Vapor
导航
验证码
杀进程
Ubuntu
Android
JWT
vue
html-js
style-class
ssh
PHP
jks
css
Runtime
tree
uniCloud
圆角
总结