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