美文网首页
iOS学习笔记-UIColor分类

iOS学习笔记-UIColor分类

作者: leyal | 来源:发表于2018-04-18 12:10 被阅读0次

    建立分类
    UIColor+SetRGB

    UIColor+SetRGB.h

    #import <UIKit/UIKit.h>
    
    @interface UIColor (SetRGB)
    //-(void)setRGB:Red:(CGFloat)r Green:(CGFloat) g Blue:(CGFloat) b;
    +(UIColor *)RGB:(CGFloat)r andG:(CGFloat)g andB:(CGFloat)b alpha:(CGFloat) alp;
    @end
    

    UIColor+SetRGB.m

    #import "UIColor+SetRGB.h"
    
    @implementation UIColor (SetRGB)
    +(UIColor *)RGB:(CGFloat)r andG:(CGFloat)g andB:(CGFloat)b alpha:(CGFloat) alp
    {
        UIColor * color = [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:alp];
        return color;
    }
    @end
    
    

    相关文章

      网友评论

          本文标题:iOS学习笔记-UIColor分类

          本文链接:https://www.haomeiwen.com/subject/bujvkftx.html