这是我的代码:
@implementation myView2
{
BOOL _touchHasBegun;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
_touchHasBegun = YES;
}
- (void)drawRect:(CGRect)rect
{
if (_touchHasBegun == YES)
{
NSLog(@"fjnv");
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context, 0, 0, 225, 1);
CGContextSetRGBFillColor(context, 0, 0, 255, 1);
CGRect rectangle = CGRectMake(50, 50, 500, 500);
CGContextStrokeEllipseInRect(context, rectangle);
}
}
我也尝试过UIButton
在按钮操作方法中UIView
设置并设置。CGRect
但这不起作用。这段代码也没有。怎么了?