【发布时间】:2011-01-12 09:02:02
【问题描述】:
我想知道是否可以在 iPad 上的UITabBar 中添加UIButton。如果有,请告诉我。
【问题讨论】:
-
你看过uibarbuttonitem developer.apple.com/library/ios/ipad/#documentation/uikit/…
我想知道是否可以在 iPad 上的UITabBar 中添加UIButton。如果有,请告诉我。
【问题讨论】:
如果您查看 @Kyle the Unruly 建议的文档,这相当简单。
这是一个添加内置按钮和您自己的图像的示例:
UIBarButtonItem * viewSnapShotButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(snapShotButtonPressed:)];
UIBarButtonItem * fontButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Font.png"] style:UIBarButtonItemStylePlain target:self action: @selector(fontSize:)];
// Add buttons to the tab bar
NSMutableArray *topCentreItems = [[NSMutableArray alloc] init];
UITabBar *topCentreTabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0, 0, 120, 75];
[topCentreItems addObject:viewSnapShotButton];
[topCentreItems addObject:fontButton];
topCentreTabBar.items = topCentreItems;
【讨论】: