#import "UIVaryColorLabel.h"
@implementation UIVaryColorLabel
#import <QuartzCore/QuartzCore.h>
#import <CoreText/CoreText.h>
- (id)initWithFrame:(CGRect)frame 此处报错为Missing context for method declaration
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
其实这个错误很简单就可以修改过来,主要是蓝色部分代码@implementation UIVaryColorLabel代码应该放到#import的后面,问题就解决了。
正确代码如下:
#import "UIVaryColorLabel.h"
#import <QuartzCore/QuartzCore.h>
#import <CoreText/CoreText.h>
@implementation UIVaryColorLabel
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}