0

我希望在 UITabbar 上放置一个 UILabel,我该如何实现呢?

4

1 回答 1

0

假设您使用的是UINavigationController带有工具栏的 a ,这应该可以解决问题:(它的两侧都有一个灵活的空间来居中。

CGRect myFrame = CGRectMake(0, 0, 100, 44);
UILabel *myLabel = [[UILabel alloc] initWithFrame:myFrame];
UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:NULL];
UIBarButtonItem *labelItem = [[UIBarButtonItem alloc] initWithCustomView:myLabel];
UIBarButtonItem *spaceItem2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:NULL];
[self setToolbarItems:[NSArray arrayWithObjects:spaceItem,labelItem,spaceItem2, nil] animated:YES];
于 2013-01-21T13:10:26.597 回答