This is a migrated thread and some comments may be shown as answers.

Place or draw something on background of listitem

1 Answer 24 Views
ListView - Xamarin.iOS
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 13 Jul 2015, 11:58 AM

Hi,

I wonder if it's possible to add/draw a coloured square/rectangle on the background of a list item. I made a sketch and added it to this post.

I've got the example projects but I couldn't find what I am looking for.

 

Many thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Sophi
Telerik team
answered on 16 Jul 2015, 12:41 PM
Hello Eric,

Yes, it is possible to get the look from the design images you have send. You should use the TKListVIewDataSource protocol and implement its cellForItem method where you should customize each cell by adding a UIView with specific color and size to it. The code sample below demonstrates this:
public override TKListViewCell CellForItem (TKListView listView, NSIndexPath indexPath)
{
    TKListViewCell cell = listView.DequeueReusableCell ("cell", indexPath) as TKListViewCell;
    cell.TextLabel.Text = "Some text";
    UIView line = new UIView (new CGRect (0, 0, 5, cell.BackgroundView.Bounds.Size.Height - 1));
    line.BackgroundColor = UIColor.Red;
    cell.BackgroundView.AddSubview (line);
    return cell;
}

If you have any other questions feel free to contact us.

Regards,
Sophi
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ListView - Xamarin.iOS
Asked by
Eric
Top achievements
Rank 1
Answers by
Sophi
Telerik team
Share this question
or