How to compare two UIColor which have almost same shade or range in iOS?

后端 未结 5 662
独厮守ぢ
独厮守ぢ 2020-12-13 16:18

I have a condition in my app where user can choose 3 colors, but those colors should not match with each other, the problem is user can choose the similar color from the pal

5条回答
  •  臣服心动
    2020-12-13 16:41

    You can use this function also.

    UIColor *color1 = [UIColor colorWithRed:1 green:(CGFloat)0.4 blue:1 alpha:1];
    UIColor *color2 = [UIColor colorWithRed:1 green:(CGFloat)0.2 blue:1 alpha:1];
    
    if (CGColorEqualToColor(color1.CGColor,color2.CGColor))
    {
        //Two colors are same
    }
    

提交回复
热议问题