Place or draw something on background of listitem

2 posts, 0 answers
  1. Eric
    Eric avatar
    16 posts
    Member since:
    May 2014

    Posted 13 Jul 2015 Link to this post

    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.

  2. Sophi
    Admin
    Sophi avatar
    99 posts

    Posted 16 Jul 2015 Link to this post

    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
  3. DevCraft banner
Back to Top