How can I set rich text properties on a UITableView footer?
I am using
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
{
if ( section == 0 )
{
return NSLocalizedString(@"Section_0_text", @"");
}
if ( section == 1 )
{
return NSLocalizedString开发者_StackOverflow(@"Section_1_text","");
}
return nil;
}
Can I modify return string text font, color and other few properties?
Take a look at the UITableViewDelegate
class, specifically the methods tableView:viewForFooterInSection:
and tableView:heightForFooterInSection:. You can return whatever kind of view you'd like, including--but not limited to--a UILabel
with whatever text properties you want.
Use the following to return your own view with custom text color etc.
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
To expand upon what willi said, keep in mind that this doesn't need to be a complicated custom view or anything. You can return a simple UILabel
object all styled with your fonts and colors, and that will work fine. In fact, it's how Apple's API docs recommend you accomplish this.
The table view uses a fixed font style for section footer titles. If you want a different font style, return a custom view (for example, a UILabel object) in the delegate method tableView:viewForFooterInSection: instead.
精彩评论