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

五、解析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);
}

 

 

 

四、获取启动页图片名spa

- (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;
}

 

 

三、延迟执行code

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

 

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

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

 

二、获取plist数据blog

    //1. 从文件中读取plist文件的路径
    NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Question" ofType:@"plist"];
    //二、从文件路径获取数据
    NSDictionary *data = [[NSDictionary alloc] initWithContentsOfFile:plistPath];
相关文章
相关标签/搜索