This tutorial demonstrates how to get started with the Telerik UI for Xamarin.iOS wrappers.
The Trial version of the UI for Xamarin.iOS wrappers is contained in the Trial package of the UI for Xamarin Cross-Platform product. You can download a Trial of UI for Xamarin Cross-Platform at http://www.telerik.com/download/xamarin-ui.
If you have already purchased UI for Xamarin.iOS, UI for Xamarin Cross-Platform or DevCraft Ultimate, you can download the wrappers following the steps below:
The UI for Xamarin Cross-Platform products gives you access to a zip file that contains the Xamarin.iOS wrappers, Xamarin.Android wrappers, UI for Windows Phone, Xamarin.Forms controls and a Demo app for these Xamarin.Forms controls. Extract the contents of the zip file to a convenient place, preferably in C:\Program Files\Telerik\UI for Xamarin\ if you are on Windows, or in Documents\Telerik\UI for Xamarin\ if you are on Mac. After you extract the contents, you can find the UI for Xamarin.iOS assembly at Binaries\iOS\Telerik.Xamarin.iOS.dll
The UI for Xamarin.iOS products gives you access to a zip file that contains the Xamarin.iOS wrappers and a Demo app for these wrappers. Extract the contents of the zip file to a convenient place, preferably in C:\Program Files\Telerik\UI for Xamarin\ if you are on Windows or in Documents\Telerik\UI for Xamarin\ if you are on Mac. The Telerik.Xamarin.iOS.dll assembly that contains the Xamarin.iOS wrappers is directly available at the top level directory of the zip contents.
After downloading and unpacking the UI for Xamarin.iOS wrappers, you can proceed with the steps below to create a new project. You can develop a Xamarin.iOS application with both Visual Studio / Xamarin Studio.
Open Visual Studio / Xamarin Studio and create a new project:
Add a reference to the Telerik.Xamarin.iOS assembly:
Open the RootViewController.cs file from the Solution tree and add the following using directives at the top of the file:
using TelerikUI;
using CoreGraphics;
using System.Collections.Generic;
Thanks to including TelerikUI we have access to the TKChart type. CoreGraphics provides access to the CGRect type for specifying the rectangle in which the Chart will be rendered, and System.Collections.Generic provides access to the generic List collection.
In the viewDidLoad method of the RootViewController, type of following code:
This code creates a new instance of TKChart and adds it as a subview of the RootViewController's main view. The autoresizingMask
property is set in order to allow correct resizing of the chart when the device is rotated in landscape mode.
In this case create two lists setting the i variable as an x value, and a random number in the range between 0 and 100 as an y value.
The TKChartLineSeries
tells the chart to present its data in the form of line charts and initialize it with the already created points.
For more information about populating TKChart with data, please refer to the following article:
For more information about customizing animations, please refer to the following articles:
You can easily change the way data is presented in the Chart by changing the series type:
chart.AddSeries(new TKChartSplineAreaSeries(randomNumericData.ToArray()));
chart.AddSeries(new TKChartSplineAreaSeries(randomNumericData2.ToArray()));