'UIColor'没有可见的@interface声明选择器'blendedColorWithFraction:ofColor:'

问题描述:

//// General Declarations 
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 
CGContextRef context = UIGraphicsGetCurrentContext(); 

//// Color Declarations 
UIColor* color = [UIColor colorWithRed: 0.623 green: 0.61 blue: 0.61 alpha: 1]; 

//// Gradient Declarations 
CGFloat gradientLocations[] = {0.62, 0.9, 1}; 
CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef)@[(id)UIColor.whiteColor.CGColor, (id)[UIColor.whiteColor blendedColorWithFraction: 0.5 ofColor: UIColor.blackColor].CGColor, (id)UIColor.blackColor.CGColor], gradientLocations); 

我正在使用一个工具,我正在制作路径并应用渐变。当我将此代码复制粘贴到Xcode时,它会告诉我们没有它不存在。'UIColor'没有可见的@interface声明选择器'blendedColorWithFraction:ofColor:'

什么是替代方法,我可以用它来代替这个。

以下是错误的截图。

enter image description here

由于

+0

看起来这只适用于OSX,不适用于iOS https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSColor_Class/#//apple_ref/occ/instm/NSColor/blendedColorWithFraction:ofColor: –

该错误消息是正确的。 blendedColorWithFraction:ofColor:NSColor method,而不是UIColor方法。

+0

什么是替代方法,以及这种方法应该做什么? –

+1

如果你不知道它应该做什么,你为什么要使用它? – matt

+0

cagradient over cashapelayer,所以我可以将颜色从黑暗变成白色。 –