iOS Question How to draw a Oval ?

shirlun

Active Member
Licensed User
Longtime User
I can't found Canvas.DrawOval in B4I, is there a replacement method ?

Thanks.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Complete example:
B4X:
Sub Process_Globals
   Public App As Application
   Public NavControl As NavigationController
   Private Page1 As Page
   Private cvs As Canvas   
End Sub

Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.Title = "Page 1"
   Page1.RootPanel.Color = Colors.White
   NavControl.ShowPage(Page1)
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
   cvs.Initialize(Page1.RootPanel)
End Sub

Sub Page1_Touch(Action As Int, X As Float, Y As Float)
   If Action = Page1.RootPanel.ACTION_DOWN Then
     Dim r As Rect
     r.Initialize(X, Y, x + 200, Y + 100)
     cvs.DrawPath(CreateOvalPath(r), Colors.Red, True, 1)
     cvs.Refresh
   End If
End Sub

Private Sub CreateOvalPath (r As Rect) As Path
   Dim no As NativeObject = Me
   Return no.RunMethod("createOvalPath:", Array(r))
End Sub

#if OBJC
- (UIBezierPath*) createOvalPath:(B4IRect*) r {
   return [UIBezierPath bezierPathWithOvalInRect:r.ToCGRect];
}
#end if
 
Upvote 0
Top