If you’re looking to use native components on IOS to build your apps one solution is the DPF IOS suite. The components in the suite actually wrap the native IOS controls just like the Delphi VCL wraps the native Windows controls. One benefit to using the native controls is that they are really fast and one drawback is that you can’t mix visual Delphi XE5 Firemonkey controls and DPF controls on the same form. In any event the DPF IOS controls come with a demo called Painter and it demonstrates how to use the DPF IOS controls to create an app like Painter that does native drawing. Painter only has one draw function which is to draw rectangles and it has a slider at the bottom which controls line with. However, you should be able to add other drawing types pretty easily once you take a look at the draw rectangle source code. DPF IOS is a pretty mature framework and has been in development since May of 2013. Here is the sample draw rect function from the demo:
procedure TFDrawingNative.DPFUIView1DrawRect( Sender: TObject; Rect: DPFNSRect );
var
context: CGContextRef;
begin
// [self.backgroundColor set];
// UIRectFill(rect);
context := UIGraphicsGetCurrentContext( );
CGContextAddPath( context, path );
CGContextSetLineCap( context, kCGLineCapRound );
CGContextSetLineWidth( context, self.lineWidth );
CGContextSetStrokeColorWithColor( context, self.lineColor.CGColor );
CGContextStrokePath( context );
isEmpty := False;
end;
Head over and download the DPF IOS suite for Delphi XE5 and check out the Painter demo.
1 Comment