我有一个按钮可以将BOOL
showSquare
更改为YES
这是按钮的代码
- (IBAction)Tap_Square:(id)sender {
[graphicsView setNeedsDisplay];
[graphicsView setShowSquare:YES];
}
这就是if语句
的地方if (showSquare) {
CGContextSetFillColorWithColor(context, white);
CGContextFillRect(context, CGRectMake(90, 90, 100, 100));
}
我做错了吗?
由于
答案 0 :(得分:0)
如果你想使用属性而不是实例变量,最好使用访问器方法来获取和设置它的值。
// use self.showSquare if you call this code in graphicsView instance
if (self.showSquare) {
CGContextSetFillColorWithColor(context, white);
CGContextFillRect(context, CGRectMake(90, 90, 100, 100));
}
同时检查您的财产是否已合成或具有吸气剂和固定剂。
答案 1 :(得分:0)
graphicsView不是零吗?
尝试将setter设置为showSquare,然后进行调试。