runtime查找 UIAlertAction 的key 及 UIActionSheet 设置字体颜色
修改不了颜色了 结果发现kvo 的key 不对 哎 直接上代码 设置正确的属性找到对应的key 还以为iOS 11改变了方法
unsigned int count;
Ivar *ivars = class_copyIvarList([UIAlertAction class], &count);
for (int i = 0; i < count; i++) {
Ivar ivar = ivars[i];
const char * cName = ivar_getName(ivar);
NSString *ocName = [NSString stringWithUTF8String:cName];
NSLog(@"%@",ocName);
}
free(ivars);
function:-[ReplayTextView takePhotoClick] line:192 content:_title
function:-[ReplayTextView takePhotoClick] line:192 content:_titleTextAlignment
function:-[ReplayTextView takePhotoClick] line:192 content:_enabled
function:-[ReplayTextView takePhotoClick] line:192 content:_checked
function:-[ReplayTextView takePhotoClick] line:192 content:_isPreferred
function:-[ReplayTextView takePhotoClick] line:192 content:_imageTintColor
function:-[ReplayTextView takePhotoClick] line:192 content:_titleTextColor
function:-[ReplayTextView takePhotoClick] line:192 content:_style
function:-[ReplayTextView takePhotoClick] line:192 content:_handler
function:-[ReplayTextView takePhotoClick] line:192 content:_simpleHandler
function:-[ReplayTextView takePhotoClick] line:192 content:_image
function:-[ReplayTextView takePhotoClick] line:192 content:_shouldDismissHandler
function:-[ReplayTextView takePhotoClick] line:192 content:__descriptiveText
function:-[ReplayTextView takePhotoClick] line:192 content:_contentViewController
function:-[ReplayTextView takePhotoClick] line:192 content:_keyCommandInput
function:-[ReplayTextView takePhotoClick] line:192 content:_keyCommandModifierFlags
function:-[ReplayTextView takePhotoClick] line:192 content:__representer
function:-[ReplayTextView takePhotoClick] line:192 content:__interfaceActionRepresentation
function:-[ReplayTextView takePhotoClick] line:192 content:__alertController
UIActionSheet 设置字体颜色 因为runtime没找到相应的key 直接去设置 但是通过 _alertController 还是能再次设置 喜迎十九大,人才辈出
- (void)takePhotoClick{
NSLog(@"z选择照片");
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:STR(@"cancel") destructiveButtonTitle:nil otherButtonTitles:STR(@"checeImgAlbum"),@"Camera ", nil];
// [sheet setValue:[UIColor colorWithHexCode:@"FD6501"] forKey:@"_titleTextColor"];
[sheet showInView:self.view];
unsigned int count;
Ivar *ivars = class_copyIvarList([UIActionSheet class], &count);
for (int i = 0; i < count; i++) {
Ivar ivar = ivars[i];
const char * cName = ivar_getName(ivar);
NSString *ocName = [NSString stringWithUTF8String:cName];
NSLog(@"%@",ocName);
}
free(ivars);
// [sheet setTintColor:[UIColor orangeColor]];
}
-(void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
SEL selector = NSSelectorFromString(@"_alertController");
if ([actionSheet respondsToSelector:selector])//ios8
{
UIAlertController *alertController = [actionSheet valueForKey:@"_alertController"];
if ([alertController isKindOfClass:[UIAlertController class]])
{
alertController.view.tintColor = [UIColor colorWithHexCode:@"FD6501"];
}
}
else//ios7
{
for( UIView * subView in actionSheet.subviews )
{
if( [subView isKindOfClass:[UIButton class]] )
{
UIButton * btn = (UIButton*)subView;
[btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
}
}
}
}
runtime查找 UIAlertAction 的key 及 UIActionSheet 设置字体颜色的更多相关文章
- Latex中如何设置字体颜色(3种方式)
Latex中如何设置字体颜色(三种方式) 1.直接使用定义好的颜色 \usepackage{color} \textcolor{red/blue/green/black/white/cyan/ma ...
- 如何在HTML中设置字体颜色,你知道这几种方式吗?
color设置字体颜色 在color设置字体颜色之前,我们首先了解color在CSS中有几种取值方式,一共有4种方式,若有不全还请在评论区告知谢谢,4种方式如下: 十六进制.十进制. 英文单词.十六进 ...
- python设置图片背景和设置字体颜色大小
# -*- coding: utf-8 -*- """ Created on Wed Dec 11 22:37:30 2019 @author: Dell "& ...
- 关于UIAlertAction如何修改sheet上的字体颜色
相信很多程序员都会遇到需求是这样的: 但是你发现无论怎么设置cancel和Destructive都无法让红色字体移动到下面取消按钮上: 其实之前一直用错,用了ios9之前的UIActionSheet这 ...
- C# 控制台程序(命令行程序)设置字体颜色,窗口宽高,光标行数
控制台程序(命令行程序)设置窗口宽度高度,如下代码: Console.WriteLine(Console.WindowHeight); Console.WriteLine(Console.Buffer ...
- C# 控制台程序设置字体颜色
这几天做了个程序,程序本身很简单.大体功能是输入查询条件,从数据库里取出结果计算并显示.但是用户的要求是使用控制台(console)来实现功能.由于功能简单,程序很快就做完了,在面向用户演示程序时,突 ...
- android 设置字体颜色、EditText自己主动输入转换成大写字母的多种方式
在TextView上面设置某一个字的字体颜色为指定颜色时,能够通过java类SpannableString类和Html语言来实现. (一)SpannableString类方式 private void ...
- wpf设置字体颜色渐变和字体阴影
<StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment=&quo ...
- c++控制台 设置字体颜色
一种方法是直接在程序上方栏杆点右键,然后属性处设置 优点是设置后一劳永逸,不需要像后面方法那样要自己把设置写入程序代码内 缺点是,一旦设置了就不能再改变了,程序从头到尾都是那种设置. 第二种方法是使用 ...
随机推荐
- Jquery13 Ajax 进阶
学习要点: 1.加载请求 2.错误处理 3.请求全局事件 4.JSON 和 JSONP 5.jqXHR 对象 一.加载请求 在 Ajax 异步发送请求时,遇到网速较慢的情况,就会出现请求时间较长的问题 ...
- Vim 基本設置 – 使用Vim-plug管理插件 (3)【转】
本文转载自:https://staryoru.github.io/vim-plugin-manager/ Vim中有很多非常好用的插件(plugin),對於這些插件的安裝.更新與移除等等,使用一個插件 ...
- 常用git代码提交命令
知识点:本篇博客记录了日常开发中,所涉及到git代码提交命令 (一)初始化本地仓库,提交代码,提交到远程git远程仓库 git init //初始化本地仓库 git add . //将当前目 ...
- 爬虫之xpath
什么是XML XML 指可扩展标记语言(EXtensible Markup Language) XML 是一种标记语言,很类似 HTML XML 的设计宗旨是传输数据,而非显示数据 XML 的标签需要 ...
- MongoDB 性能优化
Read Preferences/读写分离 有时候为了考虑应用程序的性能或响应性,为了提高读取操作的吞吐率,一个常见的措施就是进行读写分离,MongoDB副本集对读写分离的支持是通过Read Pref ...
- org.springframework.dao.DuplicateKeyException: a different object with the same identifier value was
在使用hibernate框架里面的:saveOrUpdate报错: 意思就是另一个对象的id(id同值)已经被session关联了. 原因分析: 在第1步中中通过titleList.get(0)获取一 ...
- 理解OpenID和OAuth的区别
在项目开发中,我们经常说授权认证,经常把他们放到一起去描述,那两者在本质上是有区别的,OpenID和OAuth就是我们说的认证和授权. OpenID:Authentication 认证 OAuth : ...
- Windows 10上强制Visual Studio 2017 以管理员身份运行
1. 打开VS的安装目录,找到devenv.exe,右键,选择“兼容性疑难解答”. 2. 选择“疑难解答程序” 3. 选择“该程序需要附加权限” 4. 确认用户帐户控制后,点击测试程序,不然这个对话框 ...
- Java中Collection 的基本认识
集合Conllection的基本概念:1.集合的基本认识:如StringBuffer&StringBuilder是集合(存储的对象类型是String).数组.对象与其很相似,但是还有区别.2. ...
- UVA-1623 Enter The Dragon (贪心)
题目大意:有n个装满水的湖,m天.每天可能下雨也可能晴天,只要下雨就会把湖填满,若已满,则发洪水.有一台只能在晴天使用的抽水机,每次抽水只能抽一个湖,并且全部抽光.问是否存在一种使得不发洪水的抽水方案 ...