我希望在UITabbar上放置UILabel,我该如何实现呢?
答案 0 :(得分:0)
假设您使用带有工具栏的UINavigationController
,这应该可以解决问题:
(它的两侧都有一个灵活的空间来居中。
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];