博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
常用Category
阅读量:6831 次
发布时间:2019-06-26

本文共 3963 字,大约阅读时间需要 13 分钟。

  hot3.png

#import "UIView+ISViewController.h"- (UIViewController *)viewController{    // 下一个响应者    id next = [self nextResponder];        while (next) {                next = [next nextResponder];                // 当下一个响应者派生自ViewController        if ([next isKindOfClass:[UIViewController class]]) {            return next;        }            }        return nil;}
#import "UIColor+ISColor.h"+ (UIColor *)colorWithFFRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue {    return [UIColor colorWithFFRed:red green:green blue:blue alpha:1];}+ (UIColor *)colorWithFFRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha {    return [UIColor colorWithRed:(red)/255.0 green:(green)/255.0 blue:(blue)/255.0 alpha:alpha];}+ (UIColor *)randomColor {    return [UIColor colorWithFFRed:arc4random_uniform(256) green:arc4random_uniform(256) blue:arc4random_uniform(256) alpha:arc4random_uniform(101)/100.0f];}CGFloat colorComponentFrom(NSString *string, NSUInteger start, NSUInteger length) {    NSString *substring = [string substringWithRange:NSMakeRange(start, length)];    NSString *fullHex = length == 2 ? substring : [NSString stringWithFormat: @"%@%@", substring, substring];        unsigned hexComponent;    [[NSScanner scannerWithString: fullHex] scanHexInt: &hexComponent];    return hexComponent / 255.0;}+ (UIColor *)colorWithHex:(UInt32)hex{    return [UIColor colorWithHex:hex andAlpha:1];}+ (UIColor *)colorWithHex:(UInt32)hex andAlpha:(CGFloat)alpha{    return [UIColor colorWithRed:((hex >> 16) & 0xFF)/255.0                           green:((hex >> 8) & 0xFF)/255.0                            blue:(hex & 0xFF)/255.0                           alpha:alpha];}+ (UIColor *)colorWithHexString:(NSString *)hexString {    CGFloat alpha, red, blue, green;        NSString *colorString = [[hexString stringByReplacingOccurrencesOfString:@"#" withString:@""] uppercaseString];    switch ([colorString length]) {        case 3: // #RGB            alpha = 1.0f;            red   = colorComponentFrom(colorString, 0, 1);            green = colorComponentFrom(colorString, 1, 1);            blue  = colorComponentFrom(colorString, 2, 1);            break;                    case 4: // #ARGB            alpha = colorComponentFrom(colorString, 0, 1);            red   = colorComponentFrom(colorString, 1, 1);            green = colorComponentFrom(colorString, 2, 1);            blue  = colorComponentFrom(colorString, 3, 1);            break;                    case 6: // #RRGGBB            alpha = 1.0f;            red   = colorComponentFrom(colorString, 0, 2);            green = colorComponentFrom(colorString, 2, 2);            blue  = colorComponentFrom(colorString, 4, 2);            break;                    case 8: // #AARRGGBB            alpha = colorComponentFrom(colorString, 0, 2);            red   = colorComponentFrom(colorString, 2, 2);            green = colorComponentFrom(colorString, 4, 2);            blue  = colorComponentFrom(colorString, 6, 2);            break;                    default:            return nil;    }    return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];}- (NSString *)HEXString{    UIColor* color = self;    if (CGColorGetNumberOfComponents(color.CGColor) < 4) {        const CGFloat *components = CGColorGetComponents(color.CGColor);        color = [UIColor colorWithRed:components[0]                                green:components[0]                                 blue:components[0]                                alpha:components[1]];    }    if (CGColorSpaceGetModel(CGColorGetColorSpace(color.CGColor)) != kCGColorSpaceModelRGB) {        return [NSString stringWithFormat:@"#FFFFFF"];    }    return [NSString stringWithFormat:@"#%02X%02X%02X", (int)((CGColorGetComponents(color.CGColor))[0]*255.0),            (int)((CGColorGetComponents(color.CGColor))[1]*255.0),            (int)((CGColorGetComponents(color.CGColor))[2]*255.0)];}

 

转载于:https://my.oschina.net/123009/blog/706537

你可能感兴趣的文章
MAC、IP头、TCP头、UDP头帧格式、详解
查看>>
网站前端_Highcharts-数据可视.0001.玩转Highcharts之配置快速入门?
查看>>
ECharts折线图(一)
查看>>
Linux运维工程师面试题总结
查看>>
Could not find or load main class org.apache.catalina.startup.Bootstrap
查看>>
PowerShell获取服务器本地服务状态
查看>>
禁止弹出输入法
查看>>
rsync 文件同步 服务器和客户端配置
查看>>
关于jvm的读书笔记-性能监控工具
查看>>
实习生笔试面试题总结
查看>>
版本升级提示
查看>>
FlipViewPager 对item实现左右对折滑动翻页效果《IT蓝豹》
查看>>
直接方式,反射方式,dynamic方式性能比较
查看>>
Leetcode日记5
查看>>
时间:2014年4月11日22:15:47 session 概念
查看>>
我的友情链接
查看>>
教育“优先”,落实才是关键
查看>>
传统IT大佬们,路在何方?
查看>>
基础练习
查看>>
shell学习笔记 (9.3)
查看>>