• iOS记录一常用的方法和语句


    5、解析UIColor的R,G,B的值

    - (void)getRGBDictionaryByColor:(UIColor *)originColor
    {
        CGFloat R = 0, G = 0, B = 0, A = 0;
        if ([self respondsToSelector:@selector(getRed:green:blue:alpha:)])
        {
            [originColor getRed:&R green:&G blue:&B alpha:&A];
        }else
        {
            const CGFloat *components = CGColorGetComponents(originColor.CGColor);
            R = components[0] * 255;
            G = components[1] * 255;
            B = components[2] * 255;
            A = components[3] * 100;
        }
        NSLog(@"R = %.f,%.f,%.f,%.2f",R,G,B,A);
    }

    4、获取启动页图片名

    - (NSString *)getLaunchImageName
    {
        NSString *viewOrientation = @"Portrait";
        if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
        {
            viewOrientation = @"Landscape";
        }
        NSString *launchImageName = nil;
        NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
        CGSize viewSize = [UIScreen mainScreen].bounds.size;
        for (NSDictionary* dict in imagesDict)
        {
            CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
            if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]])
            {
                launchImageName = dict[@"UILaunchImageName"];
            }
        }
        return launchImageName;
    }

    3、延迟执行

    //延迟执行
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW,(int64_t)(0.5* NSEC_PER_SEC)),dispatch_get_main_queue(),^{
        [self PandaInitParmsView];
    });

    1、当前控制器是否还显示,比较常用于网络请求回来页面已退出

    //当前视图控制器是否在显示
    +(BOOL)isCurrentViewControllerVisible:(UIViewController *)viewController
    {
        return (viewController.isViewLoaded && viewController.view.window);
    }

    2、获取plist数据

        //1. 从文件中读取plist文件的路径
        NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Question" ofType:@"plist"];
        //2、从文件路径获取数据
        NSDictionary *data = [[NSDictionary alloc] initWithContentsOfFile:plistPath];
  • 相关阅读:
    Java:Socket通信
    菜鸟玩云计算之十八:Hadoop 2.5.0 HA 集群安装第1章
    tolua reference
    严格符合CommonJS规范的包特性
    C++第11周(春)项目3
    Android动态逆向分析工具ZjDroid--脱壳神器
    报文格式【定长报文】
    OC3大回调模式使用总结(三)block回调
    Qt creator 编译错误 :cannot find file .pro qt
    OpenCV【2】---读取png图片显示到QT label上的问题
  • 原文地址:https://www.cnblogs.com/qq95230/p/7272021.html
Copyright © 2020-2023  润新知