TMS iCL DEVELOPERS GUIDE - TMS Software
TMS iCL DEVELOPERS GUIDE - TMS Software
TMS iCL DEVELOPERS GUIDE - TMS Software
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>TMS</strong> SOFTWARE<br />
<strong>TMS</strong> <strong>iCL</strong><br />
<strong>DEVELOPERS</strong> <strong>GUIDE</strong><br />
begin<br />
lbl := <strong>TMS</strong>FMXNativeUICollectionView1.AddItemTemplateLabel(10, 10,<br />
100, 25, 'Hello World !');<br />
end;<br />
The code adds a label template control descendant to the item template collection that is located<br />
under the Template property on CollectionView level. As explained in the previous chapter, the<br />
CollectionView then loads and initializes the header, footer and item elements and loops through the<br />
template collection of each element. In this sample, a native iOS UILabel will be added to the item.<br />
Initializing / modifying values<br />
After defining the template for either the header, footer and / or the item, the CollectionView<br />
initializes the elements and creates a native iOS control for each template control. The<br />
CollectionView manages each element separately in memory and reuses its elements where possible.<br />
The CollectionView does not manage a separate data structure, so the data that needs to be<br />
visualized will need to be passed by implementing some events. The “First Initialization” chapter<br />
already mentioned events to determine how many sections and items are going to be displayed.<br />
Next, after adding template controls to the header, footer and / or item with optionally default<br />
values, the data can be mapped on the control by implementing 2 events. These events are also<br />
called per element which means that we have an equivalent for the header, footer and item. In this<br />
sample code, we continue with our label template control that we have programmatically added.<br />
The code shows how to define a default font, font size and text color that will be applied to all items.<br />
procedure TForm1.FormCreate(Sender: TObject);<br />
var<br />
lbl: T<strong>TMS</strong>FMXNativeUICollectionViewTemplateLabel;<br />
begin<br />
lbl := <strong>TMS</strong>FMXNativeUICollectionView1.AddItemTemplateLabel(10, 10,<br />
100, 25, 'Hello World !');<br />
lbl.Font.Name := 'Helvetica Bold';<br />
lbl.Font.Size := 18;<br />
lbl.TextColor := TAlphaColorRec.Red;<br />
end;<br />
Running the application will show a CollectionView with 5 items per section, with red bold text and<br />
the default value “Hello World” that is set in the FormCreate.<br />
133