使用标题标题在tableview的标题部分附近显示图像的最佳方法

时间:2010-07-16 04:23:34

标签: iphone image uitableview header

我必须在带有标题标题的tableview标题部分附近显示一个图像。任何人都可以建议最好的方法吗?

提前感谢您的建议。

此致 Sathish所在

1 个答案:

答案 0 :(得分:0)

您可以尝试使用带标题和图片的导航栏:

    // show image
    UIImage *image = [UIImage imageNamed: @"bar_icon.png"];
    UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
    imageView.frame = CGRectMake(70, 0, 40, 40);
    //self.navigationItem.titleView = imageView;

    // label
    UILabel *tmpTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(120, 0, 200, 40)];
    tmpTitleLabel.text = @"Mannschaft";
    tmpTitleLabel.backgroundColor = [UIColor clearColor];
    tmpTitleLabel.textColor = [UIColor whiteColor];
    tmpTitleLabel.font = [UIFont boldSystemFontOfSize:18];

    // create new view
    CGRect applicationFrame = CGRectMake(0, 0, 300, 40);
    UIView * newView = [[[UIView alloc] initWithFrame:applicationFrame] autorelease];
    [newView addSubview:imageView];
    [newView addSubview:tmpTitleLabel];
    self.navigationItem.titleView = newView;

    [imageView release];
    [tmpTitleLabel release];
相关问题