无法从UIViewController访问UIView的UIColor属性

use*_*869 3 xcode properties uiviewcontroller uiview ios

尝试从主UIViewController在UIView子类上设置UIColor变量.我有一个属性来检索UIViewController中请求的颜色,我有一个属性,可以在UIView上接收颜色.但是,当我使用点方法应用检索到的颜色时,我得到一个错误"Property"brushColor"找不到'UIView*'类型的对象"

//Controller.h

@interface ViewController : UIViewController {
    UIColor *colorPicked;
    UIView *drawScreen;
}
@property (nonatomic, strong) UIView *drawScreen;

@property (nonatomic, strong) UIColor *colorPicked;
Run Code Online (Sandbox Code Playgroud)

//Controller.m

@implementation ViewController

@synthesize drawScreen;
@synthesize colorPicked;

- (void)viewDidLoad{   
    self.drawScreen = [[DrawingView alloc] initWithFrame:CGRectMake(0, 44, 1024, 724)];
    drawScreen.backgroundColor = [UIColor clearColor];

    drawScreen.brushColor = self.colorPicked;   //This line errors stating the property is not available on type (UIView *)

    [self.view addSubview:drawScreen];


    [super viewDidLoad];
}
Run Code Online (Sandbox Code Playgroud)

//View.h

@interface DrawingView : UIView{

    UIColor *brushColor;

    UIBezierPath *myPath;
}


@property (nonatomic, retain) UIColor *brushColor;

@end
Run Code Online (Sandbox Code Playgroud)

//View.m

@implementation DrawingView

@synthesize brushColor;

- (void)drawRect:(CGRect)rect{

    myPath = [[UIBezierPath alloc] init];

    [brushColor setStroke];

    [myPath strokeWithBlendMode:kCGBlendModeNormal alpha:1.0];

}

@end
Run Code Online (Sandbox Code Playgroud)

wat*_*n12 5

你已声明drawScreenUIView,将.h中的声明更改为

@property (nonatomic, strong) DrawingView *drawScreen;
Run Code Online (Sandbox Code Playgroud)

并更改ivar声明以匹配(或完全删除它,因为您仍在使用属性)