【发布时间】:2015-01-20 19:00:58
【问题描述】:
所以我一直在环顾四周并尝试不同的代码,但我无法真正实现我想要的。我希望在这里找到我想要的东西。
我正在尝试制作自定义数字键盘。这是我想要的结果:
但这是我得到的最接近的。
第一个问题是我无法让应用和取消按钮有边框。我该如何解决?
第二个问题是我还想在我的数字键盘上添加 +*# 按钮。我到底该怎么做?
这是我正在使用的代码:
self.numberToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
self.numberToolbar.barStyle = UIBarStyleBlackTranslucent;
self.numberToolbar.items = [NSArray arrayWithObjects:
[[UIBarButtonItem alloc]initWithTitle:@"Cancel" style:UIBarButtonItemStylePlain target:self action:@selector(cancelNumberPad)],
[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
[[UIBarButtonItem alloc]initWithTitle:@"Apply" style:UIBarButtonItemStyleDone target:self action:@selector(doneWithNumberPad)],
nil];
[self.numberToolbar sizeToFit];
self.driverNumber.inputAccessoryView = self.numberToolbar;
【问题讨论】:
-
拥有一个标题/图像为
"+*#"的按钮怎么样? -
第一张图片是旧的 iOS 6 和之前的外观。下图是新的 iOS 7 及更高版本的外观。按钮不再有边框了。
-
使用电话类型键盘而不是数字键盘。
-
Lol thnx maddy。哈哈我从来没有见过这个选项。 @maddy
标签: ios objective-c uitoolbar uitoolbaritem