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

Modifying Font Size and positioning

1 Answer 98 Views
ListView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Evan
Top achievements
Rank 1
Evan asked on 01 Mar 2016, 10:00 PM

Hi There,

I am trying to change the font size and positioning in the Telerik Example Listview project.  Which file do I need to look at to change the size and positioning of the text?

Thanks,
Evan

1 Answer, 1 is accepted

Sort by
0
Yoanna
Telerik team
answered on 02 Mar 2016, 12:11 PM
Hi Evan,

Thank you for contacting us.

By default in TKListViewCell there is a detailedTextLabel which is of UILabel type and you can change its font and position by using the default UILabel properties responsible for this.

The fallowing example shows how this could be done in the -listView: cellForItemAtIndexPath: method of TKListViewDelegate:

-(TKListViewCell *)listView:(TKListView *)listView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    TKListViewCell* cell = [listView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    cell.detailTextLabel.text = @"TELERIK TELERIK TELERIK";
    cell.detailTextLabel.frame = CGRectMake(0, 0, 100, 100);
    cell.detailTextLabel.font = [UIFont systemFontOfSize:30];
    return cell;
}

It is also possible to customize TKListView cell and add any subview to it like its shown in the example below:
@implementation ListViewSelectionCell
 
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if(self) {
         
        self.backgroundView.backgroundColor = [UIColor colorWithRed:0.969 green:0.953 blue:0.933 alpha:1];
         
        _header = [[UILabel alloc] init];
        _header.lineBreakMode = NSLineBreakByWordWrapping;
        _header.numberOfLines = 0;
        _header.font  = [UIFont fontWithName:@"Helvetica-Bold" size:15];
        _header.textColor = [UIColor colorWithRed:0.294 green:0.251 blue:0.235 alpha:1];
        [self.contentView addSubview:_header];
         
        _content = [[UILabel alloc] init];
        _content.lineBreakMode = NSLineBreakByWordWrapping;
        _content.numberOfLines = 0;
        _content.font  = [UIFont fontWithName:@"Helvetica" size:14];
        _content.textColor = [UIColor colorWithRed:0.294 green:0.251 blue:0.235 alpha:1];
        [self.contentView addSubview:_content];
         
        _favIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"fav-icon"]];
        _favIcon.hidden = YES;
        [_header addSubview:_favIcon];
                 
    }
     
    return self;
}

If you have further questions do not hesitate to contact us.

Regards,
Yoanna
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
Asked by
Evan
Top achievements
Rank 1
Answers by
Yoanna
Telerik team
Share this question
or