Xcode 无法调用方法
我试图使用[self-changeColor]调用下面的方法;得到 @MyClassViewController没有可见接口声明选择器“changeColor” 我在h和m上都是这样声明的:Xcode 无法调用方法,xcode,methods,uiimage,Xcode,Methods,Uiimage,我试图使用[self-changeColor]调用下面的方法;得到 @MyClassViewController没有可见接口声明选择器“changeColor” 我在h和m上都是这样声明的: @interface changeColor - (UIImage *) changeColor:(UIImage *)image; @end 我做错了什么? 请帮忙 -------------代码------------- 问题是[self-changeColor];changeColor和cha
@interface changeColor
- (UIImage *) changeColor:(UIImage *)image;
@end
我做错了什么?
请帮忙
-------------代码-------------
问题是
[self-changeColor];
changeColor
和changeColor:
是两个不同的东西。如果将其定义为使用一个参数,则必须这样调用
- (UIImage *) changeColor:(UIImage *)image
{
UIGraphicsBeginImageContext(image.size);
CGRect contextRect;
contextRect.origin.x = 0.0f;
contextRect.origin.y = 0.0f;
contextRect.size = [image size];
// Retrieve source image and begin image context
CGSize itemImageSize = [image size];
CGPoint itemImagePosition;
itemImagePosition.x = ceilf((contextRect.size.width - itemImageSize.width) / 2);
itemImagePosition.y = ceilf((contextRect.size.height - itemImageSize.height) );
UIGraphicsBeginImageContext(contextRect.size);
CGContextRef c = UIGraphicsGetCurrentContext();
// Setup shadow
// Setup transparency layer and clip to mask
CGContextBeginTransparencyLayer(c, NULL);
CGContextScaleCTM(c, 1.0, -1.0);
CGContextClipToMask(c, CGRectMake(itemImagePosition.x, -itemImagePosition.y, itemImageSize.width, -itemImageSize.height), [image CGImage]);
CGContextSetRGBFillColor(c, 0, 0, 1, 1);
NSLog(@"--------- METHOD DETECTED");//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> TEST
/*
switch (row)
{
case 0:
CGContextSetRGBFillColor(c, 0, 0, 1, 1);
break;
default:
CGContextSetRGBFillColor(c, 1, 0, 0., 1);
break;
}
*/
contextRect.size.height = -contextRect.size.height;
contextRect.size.height -= 15;
// Fill and end the transparency layer
CGContextFillRect(c, contextRect);
CGContextEndTransparencyLayer(c);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}