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++控制台 设置字体颜色
一种方法是直接在程序上方栏杆点右键,然后属性处设置 优点是设置后一劳永逸,不需要像后面方法那样要自己把设置写入程序代码内 缺点是,一旦设置了就不能再改变了,程序从头到尾都是那种设置. 第二种方法是使用 ...
随机推荐
- 什么时候使用namespace
#include<iostream.h> 不用using namespace std; #include<iostream>要用using namespace std;
- cygwin下烧写文件到sd卡中
在cygwin下将firmware_sdcard.bin写入到sd卡中(cygwin需要以管理员身份启动) 1查看sd分区情况 cat /proc/partitions (为了找到sd卡的标记) 2 ...
- 【转载】Eclipse 任务栏锁定问题
刚装上 Eclipse 将快捷方式拖 Win7 任务栏上了,可是打开后发现会另开一个图标并且点右键也没有锁定到任务栏的选项,很是不爽,MyEclipse 也是这样,解决方法如下. 在Eclipse目录 ...
- Spring容器基础xmlbeanfactory(一起看源码)
在spring中,如果你想创建容器少不了使用常见的xmlbeanfactory,ClassPathXmlApplicationContext,FileSystemXmlApplicationConte ...
- Lucene TF-IDF 相关性算分公式
转自: http://lutaf.com/210.htm Lucene在进行关键词查询的时候,默认用TF-IDF算法来计算关键词和文档的相关性,用这个数据排序 TF:词频,IDF:逆向文档频率,TF- ...
- 2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛-A banana·
2017-09-09 16:41:28 writer:pprp 题意很好理解就不说了,实现比较清晰,选择邻接表来做 但是我用的是链表来实现的,所以导致出现了很多问题,最后卡的最长时间的一个问题是 应该 ...
- HDU 5773 The All-purpose Zero(O(nlgn)求LIS)
http://acm.hdu.edu.cn/showproblem.php?pid=5773 题意: 求LIS,其中的0可以看做任何数. 思路: 因为0可以看做任何数,所以我们可以先不管0,先求一遍L ...
- 前端要不要学数据结构&算法
我们都知道前端开发工程师更多偏向 DOM 渲染和 DOM 交互操作,随之 Node 的推广前端工程师也可以完成服务端开发.对于服务端开发而言大家都觉得数据结构和算法是基础,非学不可.所以正在进行 No ...
- Mac 终端命令行报错 -bash: vi: command not found
我遇到的问题与这个类似,但是我的问题也是用该博文作者方法进行中断才解决的,在此表示感谢. 前段时间在 Mac 下使用终端遇到了这个问题: appledeMacBook-Air:~ air$ vi .b ...
- js中删除数组中某一项的方法
1:js中的splice方法 splice(index,len,[item]) 注释:该方法会改变原始数组. splice有3个参数,它也可以用来替换/删除/添加数组内某一个或者几个值 inde ...