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

Align Image in TKSideDrawerItem

3 Answers 43 Views
SideDrawer
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sal
Top achievements
Rank 1
Sal asked on 07 Aug 2015, 06:24 PM
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). 

3 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 10 Aug 2015, 03:47 PM
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
0
Sal
Top achievements
Rank 1
answered on 10 Aug 2015, 05:25 PM
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. 
0
Jack
Telerik team
answered on 11 Aug 2015, 12:47 PM
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
Tags
SideDrawer
Asked by
Sal
Top achievements
Rank 1
Answers by
Jack
Telerik team
Sal
Top achievements
Rank 1
Share this question
or