Modifying Font Size and positioning

2 posts, 0 answers
  1. Evan
    Evan avatar
    1 posts
    Member since:
    Mar 2016

    Posted 01 Mar Link to this post

    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

  2. Yoanna
    Admin
    Yoanna avatar
    44 posts

    Posted 02 Mar Link to this post

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