1

所以我有一个导航栏,我想自定义和居中,无论我做什么,我都会像这样平铺图像。

self.navigation.titleView这是我用来设置的代码UITableControllerView

self.navigationItem.titleView = [self titleView]; // happens in viewDidLoad

- (UIView *)titleView{
UIImage *headerImage = [UIImage imageNamed:@"header@2x"];
UIImageView *containerView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, headerImage.size.width, headerImage.size.height)];


return containerView;

}

谢谢。

4

1 回答 1

0
UIImageView *imgtitle = [[UIImageView alloc]    initWithFrame:CGRectMake(0, 0, 100, 25)];
    [imgtitle setContentMode:UIViewContentModeCenter];
    self.navigationItem.titleView = imgtitle;
    imgtitle.image = [UIImage imageNamed:@"logo.png"];
于 2012-12-07T06:35:28.387 回答