• 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];

                    

                }

                

            }

            

        }

        

    }

  • 相关阅读:
    BZOJ-2462: [BeiJing2011]矩阵模板 (宇宙无敌超级大暴力~)
    BZOJ-3555: [Ctsc2014]企鹅QQ (hash)
    BZOJ-3098: Hash Killer II (未知)
    [SinGuLaRiTy] 2017 百度之星程序设计大赛 初赛A
    [SinGuLaRiTy] 树链问题
    [SinGuLaRiTy] 2017 百度之星程序设计大赛-资格赛
    [SinGuLaRiTy] NOIP模拟赛(TSY)-Day 2
    [SinGuLaRiTy] NOIP模拟赛(TSY)-Day 1
    [SinGuLaRiTy] 2017-07-26 综合性测试
    [SinGuLaRiTy] NOIP 膜你赛-Day 2
  • 原文地址:https://www.cnblogs.com/tangyuanby2/p/7605476.html
Copyright © 2020-2023  润新知