I created a class newView from UIView and aim to draw a quadrangle. the 4 coners (ClipPointA, ClipPointB, ClipPointC, ClipPointD) of the quadrangle are supposed to read value from ViewController.
newView.h:
@interface newView : UIView {
CGPoint ClipPointA, ClipPointB, ClipPointC, ClipPointD;
}
@end
newView.m:
@implementation newView
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Initialization code.
}
return self;
}
- (void)drawRect:(CGRect)rect {
// Drawing code.
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context, 1.0, 1.0, 0.0, 1.0);
CGContextBeginPath(context);
CGContextMoveToPoint(context, ClipPointA.x, ClipPointA.y); //start point
CGContextAddLineToPoint(context, ClipPointB.x, ClipPointB.y);
CGContextAddLineToPoint(context, ClipPointD.x, ClipPointD.y);
CGContextAddLineToPoint(context, ClipPointC.x, ClipPointC.y); // end path
CGContextClosePath(context); // close path
CGContextSetLineWidth(context, 2.0);
CGContextStrokePath(context);
}
- (void)dealloc {
[super dealloc];
}
@end
I created the instance of newView in ViewController. How do I write next part of code to let 4 CGPoints read value from ViewController?
Thanks.