smaller view on header

Discussion in 'iOS Programming' started by jagatnibas, Oct 14, 2011.

  1. jagatnibas, Oct 14, 2011
    Last edited by a moderator: Oct 14, 2011

    jagatnibas macrumors regular

    Jul 28, 2008
    Hi all,

    I am trying to use a button as a custom header for UITableView

    using following function

    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section  {
    	[btnHeader setTitle:(NSString *)[@"Title"] forState:UIControlStateNormal];
        return btnHeader;
    no matter how small i give the CGRect, it is expanded to cover fill header width !

    how can I keep this button view to a certain width may be 100 px, not stretched to entire row / section length ?

    thanks in advance and regards
  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    Create a UIView then add your button to that. Return the UIView as the header.

Share This Page