Align Image in TKSideDrawerItem

4 posts, 0 answers
  1. Sal
    Sal avatar
    58 posts
    Member since:
    Feb 2015

    Posted 07 Aug 2015 Link to this post

    I just started working on replacing some of the other third party tools we were using with ones within the Telerik library, and for the SideDrawer I need to know if there's a way to move the alignment on the Image in a TKSideDrawerItem, I can easily center align the text with item.style.textAlignment = NSTextAlignment.Center but there's nothing that can be done to have the Image move to the center as well (but to the left of the label). 
  2. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 10 Aug 2015 Link to this post

    Hi Sal,

    Currently this feature is not available out of the box in TKSideDrawer. You should adopt TKSideDrawerDelegate and implement its sideDrawer:cellForItemAtIndexPath: method to replace the default TKSideDrawerTableViewCell: with a custom one. After that you can use layoutSubviews method in your custom cell to set the right frame for the imageView. Consider the following code snippet:
    - (TKSideDrawerTableViewCell *)sideDrawer:(TKSideDrawer *)sideDrawer cellForItemAtIndexPath:(NSIndexPath *)indexPath;
    {
        MySideDrawerCell *cell = [[MySideDrawerCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        NSArray *sections = sideDrawer.sections;
        TKSideDrawerSection *section = sections[indexPath.section];
        TKSideDrawerItem *sideDrawerItem = section.items[indexPath.row];
        cell.item = sideDrawerItem;
        return cell;
    }

    @interface MySideDrawerCell : TKSideDrawerTableViewCell
     
    @end
     
    @implementation MySideDrawerCell
     
    - (void)layoutSubviews
    {
        [super layoutSubviews];
        self.imageView.frame = CGRectMake(100, 5, 20, 20);
    }
     
    @end

    I think that this will be a nice addition to our TKSideDrawer and I logged it in our feedback portal. You can use the following link to track the issue status and vote/comment on it. Your Telerik points are updated accordingly.

    Should you have other questions, do not hesitate to ask.

    Regards,
    Jack
    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
  4. Sal
    Sal avatar
    58 posts
    Member since:
    Feb 2015

    Posted 10 Aug 2015 in reply to Jack Link to this post

    Thanks Jack, I'll try out what you have posted to see if that works of what I need and then keep track of the issue as well. 
  5. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 11 Aug 2015 Link to this post

    Hi Sal,

    Thanks for writing us back. I hope the solution will fit in your scenario. Feel free to contact us if you need further assistance.

    Regards,
    Jack
    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
Back to Top
DevCraft banner