尝试从主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)